import { ApiProperty } from '@nestjs/swagger'; import { IsNotEmpty, IsArray, ValidateNested, ArrayMinSize, IsInt, Min, IsString } from 'class-validator'; import { Type } from 'class-transformer'; class AddItemToCartDto { @ApiProperty({ description: 'Quantity of the product item', example: 1, minimum: 1 }) @IsNotEmpty() @Type(() => Number) @IsInt() @Min(1) quantity!: number; @ApiProperty({ description: 'Product ID' }) @IsNotEmpty() @IsString() variantId!: string; } export class BulkAddItemsToCartDto { @ApiProperty({ description: 'Array of items to add to cart', type: [AddItemToCartDto], example: [ { variantId: 'product-123', quantity: 2 }, { variantId: 'product-456', quantity: 1 }, ], }) @IsNotEmpty() @IsArray() @ArrayMinSize(1, { message: 'At least one item is required' }) @ValidateNested({ each: true }) @Type(() => AddItemToCartDto) items!: AddItemToCartDto[]; }