30 lines
712 B
TypeScript
30 lines
712 B
TypeScript
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: 'Product ID' })
|
|
@IsNotEmpty()
|
|
@IsString()
|
|
variantId!: string;
|
|
|
|
@ApiProperty({ description: 'Quantity of the product 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[];
|
|
}
|