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