import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString, IsArray, ValidateNested, IsInt, Min } from 'class-validator';
import { Type } from 'class-transformer';

export class CartItemDto {
  @ApiProperty({ description: 'Food ID' })
  @IsNotEmpty()
  @IsString()
  foodId!: string;

  @ApiProperty({ description: 'Quantity of the food item', example: 2, minimum: 1 })
  @IsNotEmpty()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  quantity!: number;
}

export class CreateCartDto {
  @ApiProperty({
    description: 'List of cart items',
    type: [CartItemDto],
  })
  @IsNotEmpty()
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => CartItemDto)
  items!: CartItemDto[];
}
