big boi refactor to customer inof from passenger info
This commit is contained in:
46
packages/logic/domains/customerinfo/data.ts
Normal file
46
packages/logic/domains/customerinfo/data.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
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
|
||||
>;
|
||||
Reference in New Issue
Block a user