瀏覽代碼

feat(stats-reporting): add validation and transformation decorators for fromSec and toSec in BaseRangeQueryDto

Dave 1 月之前
父節點
當前提交
492aaeef48
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      apps/box-stats-api/src/feature/stats-reporting/dto/stats-reporting.dto.ts

+ 6 - 0
apps/box-stats-api/src/feature/stats-reporting/dto/stats-reporting.dto.ts

@@ -1,16 +1,22 @@
 import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
+import { Type } from 'class-transformer';
+import { IsInt } from 'class-validator';
 
 export class BaseRangeQueryDto {
   @ApiProperty({
     description: 'UTC epoch seconds (inclusive)',
     example: 1767168000,
   })
+  @Type(() => Number)
+  @IsInt()
   fromSec!: number;
 
   @ApiProperty({
     description: 'UTC epoch seconds (exclusive)',
     example: 1767175200,
   })
+  @Type(() => Number)
+  @IsInt()
   toSec!: number;
 
   @ApiPropertyOptional({