File size: 1,796 Bytes
2b109bf 20b4530 2b109bf 20b4530 2b109bf 20b4530 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | import { z } from 'zod';
const nestedRegister = z.object({
gym: z.object({
name: z.string().min(2),
email: z.string().email().optional(),
phone: z.string().min(5).optional(),
address: z.string().optional(),
}),
owner: z.object({
name: z.string().min(2),
email: z.string().email(),
password: z.string().min(8),
phone: z.string().min(5).optional(),
nationalId: z.string().min(5).optional(),
}),
});
const flatRegister = z.object({
ownerName: z.string().min(2),
email: z.string().email(),
password: z.string().min(8),
gymName: z.string().min(2),
gymAddress: z.string().optional(),
gymPhone: z.string().min(5).optional(),
ownerPhone: z.string().min(5).optional(),
ownerNationalId: z.string().min(5).optional(),
});
export const registerSchema = z.object({
body: z.union([nestedRegister, flatRegister]),
});
export const loginSchema = z.object({
body: z.object({
email: z.string().email(),
password: z.string().min(1),
}),
});
export const refreshSchema = z.object({
body: z.object({
refreshToken: z.string().min(20),
}),
});
export const checkEmailSchema = z.object({
query: z.object({
email: z.string().email(),
}),
});
export const forgotPasswordSchema = z.object({
body: z.object({
email: z.string().email(),
}),
});
export const verifyOtpSchema = z.object({
body: z.object({
email: z.string().email(),
otp: z.string().regex(/^\d{6}$/),
}),
});
export const resetPasswordSchema = z.object({
body: z.object({
email: z.string().email(),
otp: z.string().regex(/^\d{6}$/),
newPassword: z.string().min(8),
}),
});
export const changePasswordSchema = z.object({
body: z.object({
currentPassword: z.string().min(1),
newPassword: z.string().min(8),
}),
});
|