import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { OrderStatus } from '@prisma/client'; import { Transform, Type } from 'class-transformer'; import { IsDate, IsInt, IsNotEmpty, IsNumber, IsOptional } from 'class-validator'; export class CreateOrderDto { @ApiPropertyOptional() @IsOptional() @IsDate() @Type(() => Date) orderDate?: Date; @ApiPropertyOptional({ enum: OrderStatus, enumName: 'OrderStatus' }) @IsOptional() status?: OrderStatus; @ApiProperty() @IsNotEmpty() @IsNumber() @Transform(({ value }) => parseFloat(value)) total!: number; @ApiProperty() @IsNotEmpty() @IsInt() @Transform(({ value }) => parseInt(value, 10)) customerId!: number; @ApiPropertyOptional() @IsOptional() @IsDate() @Type(() => Date) createdAt?: Date; }