From d8553e7c09f5b3b32ac50c7f40c1a1cbaee5a764 Mon Sep 17 00:00:00 2001 From: Aik Chun Date: Tue, 3 Aug 2021 12:41:29 +0800 Subject: [PATCH] Add transform decorator to limit the size property of PaignationQuery to 60. (#300) --- apps/whale-api/src/module.api/_core/api.query.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/whale-api/src/module.api/_core/api.query.ts b/apps/whale-api/src/module.api/_core/api.query.ts index a6727ee54f..7229e7fa6e 100644 --- a/apps/whale-api/src/module.api/_core/api.query.ts +++ b/apps/whale-api/src/module.api/_core/api.query.ts @@ -1,5 +1,5 @@ -import { IsInt, IsOptional, IsString, Max, Min } from 'class-validator' -import { Type } from 'class-transformer' +import { IsInt, IsOptional, IsString, Min } from 'class-validator' +import { Type, Transform } from 'class-transformer' /** * Pagination query with @@ -11,8 +11,8 @@ import { Type } from 'class-transformer' export class PaginationQuery { @IsOptional() @IsInt() + @Transform(({ value }) => value > 60 ? 60 : value) @Min(0) - @Max(60) @Type(() => Number) size: number = 30