import { z } from 'zod'

export const registerSchema = z.object({
  orgName: z.string().min(2, '企业名称至少2个字').max(50, '企业名称最多50个字'),
  phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
  password: z.string().min(8, '密码至少8位').max(32, '密码最多32位'),
  confirmPassword: z.string(),
}).refine((data) => data.password === data.confirmPassword, {
  message: '两次密码不一致',
  path: ['confirmPassword'],
})

export const loginSchema = z.object({
  phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
  password: z.string().min(1, '请输入密码'),
})

export const refreshSchema = z.object({
  refreshToken: z.string().min(1, '缺少 refreshToken'),
})

export const forgotPasswordSchema = z.object({
  phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
})

export const resetPasswordSchema = z.object({
  phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
  code: z.string().length(6, '验证码为6位数字'),
  newPassword: z.string().min(8, '密码至少8位').max(32, '密码最多32位'),
})

export const verifyCodeSchema = z.object({
  phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
  code: z.string().length(6, '验证码为6位数字'),
  newPassword: z.string().min(8, '密码至少8位').max(32, '密码最多32位'),
})
