Skip to content

Commit 82be407

Browse files
committed
fix: select fields conflict
1 parent bd6c849 commit 82be407

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

src/common/validation/is-enum-param.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface
22
import { QueryParamStrategyFactory } from '../query-builder/query-param-strategy/query-param.strategy';
33
import { ExcludeQueryParamStrategy } from '../query-builder/query-param-strategy/exclude-query-param.strategy';
44
import { IncludeQueryParamStrategy } from '../query-builder/query-param-strategy/include-query-param.strategy';
5+
import { Logger } from '@nestjs/common';
56

67
@ValidatorConstraint({ name: 'isEnumParam', async: false })
78
export class IsEnumParam implements ValidatorConstraintInterface {
9+
private readonly logger = new Logger(IsEnumParam.name);
810
validate(value: any, args: ValidationArguments) {
911
if (Array.isArray(value)) return value.every((item) => this.validate(item, args));
1012

@@ -20,6 +22,12 @@ export class IsEnumParam implements ValidatorConstraintInterface {
2022
if (value === undefined || value === null) return false;
2123
if (value === '') return true;
2224

23-
return !!args.constraints[0][value];
25+
const isValid = !!args.constraints[0][value];
26+
27+
if (!isValid) {
28+
this.logger.warn(`Value ${value} is not valid enum value! Enum: ${Object.keys(args.constraints[0]).join(', ')}`);
29+
}
30+
31+
return isValid;
2432
}
2533
}

src/movie/dto/v1.4/movie-request.dto.ts

+21-10
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ export enum MovieFieldV1_4 {
111111
'watchability.items.url' = 'watchability.items.url',
112112
'watchability.items.logo.url' = 'watchability.items.logo.url',
113113
lists = 'lists',
114+
top10 = 'top10',
115+
top250 = 'top250',
114116
}
115117
export enum MovieSelectFieldV1_4 {
116118
'id' = 'id',
@@ -153,30 +155,39 @@ export enum MovieSelectFieldV1_4 {
153155
'sequelsAndPrequels' = 'sequelsAndPrequels',
154156
'watchability' = 'watchability',
155157
lists = 'lists',
158+
top10 = 'top10',
159+
top250 = 'top250',
156160
}
157161

158162
const defaultSelectFields = [
159163
'id',
160-
'externalId',
161164
'name',
162-
'logo',
163-
'poster',
164165
'alternativeName',
165166
'enName',
166-
'names',
167+
'type',
168+
'year',
167169
'description',
168170
'shortDescription',
169-
'horizontalPoster',
170-
'type',
171171
'movieLength',
172-
'seriesLength',
172+
'isSeries',
173+
'ticketsOnSale',
173174
'totalSeriesLength',
174-
'year',
175-
'votes',
175+
'seriesLength',
176+
'ratingMpaa',
177+
'ageRating',
178+
'top10',
179+
'top250',
180+
'typeNumber',
181+
'status',
182+
'names',
183+
'logo',
184+
'poster',
185+
'backdrop',
176186
'rating',
177-
'releaseYears',
187+
'votes',
178188
'genres',
179189
'countries',
190+
'releaseYears',
180191
];
181192

182193
export enum MovieTypeV1_4 {

0 commit comments

Comments
 (0)