import { z } from 'zod'; const phoneRegex = /^(0|\+84)(3[2-9]|5[2689]|7[06-9]|8[1-9]|9[0-9])\d{7}$/; export const loginSchema = z.object({ phone: z .string() .min(1, 'Vui lòng nhập số điện thoại') .regex(phoneRegex, 'Số điện thoại không hợp lệ'), password: z.string().min(1, 'Vui lòng nhập mật khẩu'), }); export const registerSchema = z .object({ fullName: z .string() .min(1, 'Vui lòng nhập họ tên') .min(2, 'Họ tên phải có ít nhất 2 ký tự'), phone: z .string() .min(1, 'Vui lòng nhập số điện thoại') .regex(phoneRegex, 'Số điện thoại không hợp lệ'), email: z .string() .email('Email không hợp lệ') .optional() .or(z.literal('')), password: z .string() .min(8, 'Mật khẩu phải có ít nhất 8 ký tự'), confirmPassword: z.string().min(1, 'Vui lòng xác nhận mật khẩu'), }) .refine((data) => data.password === data.confirmPassword, { message: 'Mật khẩu xác nhận không khớp', path: ['confirmPassword'], }); export type LoginFormData = z.infer; export type RegisterFormData = z.infer;