feat: add booking input validation

This commit is contained in:
que01 committed 2026-09-18 16:29:54 +08:00
1 parent 1e03d055aa
commit ae5f26baab
3 files changed
+47 -5

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
import { Type } from "class-transformer";
import {
IsArray,
IsIn,
IsInt,
IsISO8601,
IsOptional,
IsString,
Max,
Min,
ValidateNested,
} from "class-validator";
export class BookingItemDto {
@IsString() serviceId!: string;
@IsInt() @Min(1) @Max(50) quantity!: number;
}
export class CreateBookingDto {
@IsIn(["package", "private_chef"]) requestType!: "package" | "private_chef";
@IsString() customerName!: string;
@IsOptional() @IsString() phone?: string;
@IsOptional() @IsString() wechatId?: string;
@IsIn(["wechat", "phone", "none"]) contactPreference!: "wechat" | "phone" | "none";
@IsOptional() @IsIn(["pickup", "delivery"]) fulfillmentType?: "pickup" | "delivery";
@IsOptional() @IsString() serviceId?: string;
@IsOptional() @IsISO8601() requestedDate?: string;
@IsOptional() @IsString() requestedTime?: string;
@IsOptional() @IsString() deliveryAddress?: string;
@IsOptional() @IsString() note?: string;
@IsOptional() extraData?: Record<string, unknown>;
@IsArray() @ValidateNested({ each: true }) @Type(() => BookingItemDto) items: BookingItemDto[] =
[];
}