feat: add booking input validation
This commit is contained in:
1 parent
1e03d055aa
commit
ae5f26baab
3 files changed
+47
-5
No files matched your search
@@ -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[] =
|
||||
[];
|
||||
}
|
||||
Reference in new issue
Block a user