| 1 | import { z } from 'zod'; |
| 2 | |
| 3 | export type { |
| 4 | User, |
| 5 | LoginCredentials, |
| 6 | RegisterData, |
| 7 | AuthResponse, |
| 8 | } from '@/types'; |
| 9 | |
| 10 | export const loginSchema = z.object({ |
| 11 | email: z.string().email({ message: 'Invalid email address' }), |
| 12 | password: z |
| 13 | .string() |
| 14 | .min(6, { message: 'Password must be at least 6 characters long' }), |
| 15 | }); |
| 16 | |
| 17 | export const registerSchema = z |
| 18 | .object({ |
| 19 | name: z |
| 20 | .string() |
| 21 | .min(2, { message: 'Name must be at least 2 characters long' }), |
| 22 | email: z.string().email({ message: 'Invalid email address' }), |
| 23 | password: z |
| 24 | .string() |
| 25 | .min(6, { message: 'Password must be at least 6 characters long' }), |
| 26 | confirmPassword: z.string().min(6, { |
| 27 | message: 'Confirm Password must be at least 6 characters long', |
| 28 | }), |
| 29 | }) |
| 30 | .refine((data) => data.password === data.confirmPassword, { |
| 31 | message: 'Passwords do not match', |
| 32 | path: ['confirmPassword'], |
| 33 | }); |
| 34 | |
| 35 | export type LoginFormData = z.infer<typeof loginSchema>; |
| 36 | export type RegisterFormData = z.infer<typeof registerSchema>; |