Advertisement
nodejsdeveloperskh

extends in class-validator (NestJS)

Aug 9th, 2021
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class PaginationQueryStringDto {
  2.     @IsOptional()
  3.     @IsNumber(
  4.         { allowInfinity: false, allowNaN: false },
  5.         { message: 'page_should_be_number'.toUpperCase() },
  6.     )
  7.     page: number;
  8.  
  9.     @IsOptional()
  10.     @IsNumber(
  11.         { allowInfinity: false, allowNaN: false },
  12.         { message: 'limit_should_be_number'.toUpperCase() },
  13.     )
  14.     limit: number;
  15. }
  16.  
  17. class ProjectFiltersByUserDto extends PaginationQueryStringDto {
  18.     @IsOptional()
  19.     @IsString({ message: 'province_should_be_string'.toUpperCase() })
  20.     @IsMongoId({ message: 'province_should_be_object_id'.toUpperCase() })
  21.     province: string;
  22.  
  23.     @IsOptional()
  24.     @IsString({ message: 'endDate_should_be_string'.toUpperCase() })
  25.     endDate: string;
  26.  
  27.     @IsOptional()
  28.     @IsString({ message: 'startDate_should_be_string'.toUpperCase() })
  29.     startDate: string;
  30.  
  31.     @IsOptional()
  32.     @IsString({ message: 'serviceTypeId_should_be_string'.toUpperCase() })
  33.     @IsMongoId({ message: 'serviceTypeId_should_be_object_id'.toUpperCase() })
  34.     serviceTypeId: string;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement