import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Transform, Type } from 'class-transformer'; import { IsDate, IsInt, IsNotEmpty, IsNumber, IsOptional } from 'class-validator'; export class CreateOrderItemDto { @ApiProperty() @IsNotEmpty() @IsInt() @Transform(({ value }) => parseInt(value, 10)) quantity!: number; @ApiProperty() @IsNotEmpty() @IsNumber() @Transform(({ value }) => parseFloat(value)) price!: number; @ApiProperty() @IsNotEmpty() @IsInt() @Transform(({ value }) => parseInt(value, 10)) orderId!: number; @ApiProperty() @IsNotEmpty() @IsInt() @Transform(({ value }) => parseInt(value, 10)) productId!: number; @ApiPropertyOptional() @IsOptional() @IsDate() @Type(() => Date) createdAt?: Date; }