Raw
1 import i18n from "i18next"
2 import { z } from "zod"
3
4 export const AddressSchema = z.object({
5 first_name: z.string().min(1),
6 last_name: z.string().min(1),
7 company: z.string().optional(),
8 address_1: z.string().min(1),
9 address_2: z.string().optional(),
10 city: z.string().min(1),
11 postal_code: z.string().min(1),
12 province: z.string().optional(),
13 country_code: z.string().min(1),
14 phone: z.string().optional(),
15 })
16
17 export const EmailSchema = z.object({
18 email: z.string().email(),
19 })
20
21 export const TransferOwnershipSchema = z
22 .object({
23 current_owner_id: z.string().min(1),
24 new_owner_id: z
25 .string()
26 .min(1, i18n.t("transferOwnership.validation.required")),
27 })
28 .superRefine((data, ctx) => {
29 if (data.current_owner_id === data.new_owner_id) {
30 return ctx.addIssue({
31 code: z.ZodIssueCode.custom,
32 path: ["new_owner_id"],
33 message: i18n.t("transferOwnership.validation.mustBeDifferent"),
34 })
35 }
36 })