import { IsArray, IsNumber, IsNotEmpty, ArrayMinSize } from 'class-validator'; import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; export class InvoiceItemDto { @IsNumber() @ApiProperty() productId: number; @ApiProperty() @IsArray() attributesValues: string[] @ApiProperty() @IsNumber() quantity: number @ApiProperty() @IsNumber() unitPrice: number @ApiProperty() @IsNumber() discount: number } export class AddOrderItemDto { @IsArray() @ApiProperty({ isArray: true, type: [InvoiceItemDto], example: [ { orderItemId: 1, unitPrice: 100, } ] }) @IsNotEmpty() @ArrayMinSize(1, { message: 'At least one product is required' }) @Type(() => InvoiceItemDto) items: InvoiceItemDto[]; }