47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const customerInfoModel = z.object({
|
|
id: z.number().optional(),
|
|
firstName: z.string().min(1).max(64),
|
|
middleName: z.string().max(64).default(""),
|
|
lastName: z.string().min(1).max(64),
|
|
email: z.string().email().max(128),
|
|
phoneCountryCode: z.string().min(1).max(6),
|
|
phoneNumber: z.string().min(1).max(20),
|
|
country: z.string().min(1).max(128),
|
|
state: z.string().min(1).max(128),
|
|
city: z.string().min(1).max(128),
|
|
zipCode: z.string().min(1).max(21),
|
|
address: z.string().min(1),
|
|
address2: z.string().optional().nullable(),
|
|
orderId: z.number().optional().nullable(),
|
|
createdAt: z.coerce.string().optional(),
|
|
updatedAt: z.coerce.string().optional(),
|
|
});
|
|
|
|
export type CustomerInfoModel = z.infer<typeof customerInfoModel>;
|
|
|
|
export const createCustomerInfoPayload = customerInfoModel.omit({
|
|
id: true,
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
});
|
|
|
|
export type CreateCustomerInfoPayload = z.infer<
|
|
typeof createCustomerInfoPayload
|
|
>;
|
|
|
|
export const updateCustomerInfoPayload = customerInfoModel
|
|
.omit({
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
})
|
|
.partial()
|
|
.extend({
|
|
id: z.number(),
|
|
});
|
|
|
|
export type UpdateCustomerInfoPayload = z.infer<
|
|
typeof updateCustomerInfoPayload
|
|
>;
|