Browse Source

refactor upload DTO

Dave 1 tháng trước cách đây
mục cha
commit
927dab4636

+ 7 - 0
apps/box-mgnt-api/src/mgnt-backend/feature/uploader/uploader.dto.ts

@@ -1,4 +1,5 @@
 import { ApiProperty } from '@nestjs/swagger';
+import { IsIn, IsNotEmpty, IsString } from 'class-validator';
 import { UploadFileType } from './uploader.service';
 
 export class UploadRequestDto {
@@ -7,6 +8,8 @@ export class UploadRequestDto {
       'Target folder path (relative, no leading slash). Example: ads/banner or video/preview',
     example: 'ads/banner',
   })
+  @IsString()
+  @IsNotEmpty()
   folder: string;
 
   @ApiProperty({
@@ -14,6 +17,8 @@ export class UploadRequestDto {
       'Target filename including extension. Uploader does not modify the name.',
     example: 'abc123.jpg',
   })
+  @IsString()
+  @IsNotEmpty()
   filename: string;
 
   @ApiProperty({
@@ -22,5 +27,7 @@ export class UploadRequestDto {
     enum: ['video', 'image', 'voice', 'other'],
     example: 'image',
   })
+  @IsString()
+  @IsIn(['video', 'image', 'voice', 'other'])
   fileType: UploadFileType;
 }