Skip to content

Commit a0ce32f

Browse files
committed
style(dto): produce the class using chain calls
1 parent 3b6a0c8 commit a0ce32f

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

src/dtos/query-dto.factory.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,26 @@ export class QueryDtoFactory<Entity> extends AbstractFactory<QueryDto<Entity>> {
2020
const commonDecorators = [IsOptional()];
2121
const numericDecorators = [IsNumber(), Type(), Min(1)];
2222

23-
this.defineTypeMetadata("limit", Number);
24-
this.applyPropertyDecorators(
25-
"limit",
26-
...commonDecorators,
27-
...numericDecorators,
28-
...(options.limit?.max ? [Max(options.limit.max)] : [])
29-
);
30-
31-
this.defineTypeMetadata("offset", Number);
32-
this.applyPropertyDecorators(
33-
"offset",
34-
...commonDecorators,
35-
...numericDecorators,
36-
...(options.offset?.max ? [Max(options.offset.max)] : [])
37-
);
38-
39-
this.defineTypeMetadata("expand", Array);
40-
this.applyPropertyDecorators(
41-
"expand",
42-
...commonDecorators,
43-
Type((type) => String),
44-
IsIn(options.expand?.in ?? [], { each: true })
45-
);
23+
this.defineTypeMetadata("limit", Number)
24+
.applyPropertyDecorators(
25+
"limit",
26+
...commonDecorators,
27+
...numericDecorators,
28+
...(options.limit?.max ? [Max(options.limit.max)] : [])
29+
)
30+
.defineTypeMetadata("offset", Number)
31+
.applyPropertyDecorators(
32+
"offset",
33+
...commonDecorators,
34+
...numericDecorators,
35+
...(options.offset?.max ? [Max(options.offset.max)] : [])
36+
)
37+
.defineTypeMetadata("expand", Array)
38+
.applyPropertyDecorators(
39+
"expand",
40+
...commonDecorators,
41+
Type((type) => String),
42+
IsIn(options.expand?.in ?? [], { each: true })
43+
);
4644
}
4745
}

0 commit comments

Comments
 (0)