diff --git a/src/modules/products/dto/create-product.dto.ts b/src/modules/products/dto/create-product.dto.ts index 126e886..604beb3 100644 --- a/src/modules/products/dto/create-product.dto.ts +++ b/src/modules/products/dto/create-product.dto.ts @@ -1,5 +1,6 @@ import { Type } from 'class-transformer'; import { + ArrayMinSize, IsArray, IsBoolean, IsEnum, @@ -10,19 +11,19 @@ import { IsString, Min, Length, + ValidateNested, } from 'class-validator'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; export class CreateVariantDto { - @IsString() @IsOptional() + @IsString() @ApiPropertyOptional() id: string @IsString() @ApiProperty() @IsOptional() - @IsNotEmpty() value: string @IsNumber() @@ -50,8 +51,10 @@ export class CreateProductDto { @ApiPropertyOptional({ example: 'مثلا رنگ ،سایز' }) attribute?: string; - @IsOptional() - @Length(1, 100) + @IsArray() + @ArrayMinSize(1) + @ValidateNested({ each: true }) + @Type(() => CreateVariantDto) @ApiPropertyOptional({ type: CreateVariantDto, example: [{