import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Transform, Type } from 'class-transformer'; import { IsBoolean, IsDate, IsInt, IsNotEmpty, IsNumber, IsOptional, IsString } from 'class-validator'; export class CreateProductDto { @ApiProperty() @IsNotEmpty() @IsString() name!: string; @ApiPropertyOptional() @IsOptional() @IsString() description?: string | null; @ApiProperty() @IsNotEmpty() @IsNumber() @Transform(({ value }) => parseFloat(value)) price!: number; @ApiProperty() @IsNotEmpty() @IsString() sku!: string; @ApiPropertyOptional() @IsOptional() @IsBoolean() inStock?: boolean; @ApiPropertyOptional() @IsOptional() @IsNumber() @Transform(({ value }) => parseFloat(value)) weight?: number | null; @ApiPropertyOptional() @IsOptional() @IsDate() @Type(() => Date) createdAt?: Date; @ApiPropertyOptional() @IsOptional() @IsInt() @Transform(({ value }) => parseInt(value, 10)) categoryId?: number | null; }