// 请假表单 Zod schema
// 依据：project_rules §3.8 输入验证、02-architecture-design.md §15 组件设计
// - 请假类型：sick/personal/family/other
// - 日期范围：结束日期 >= 开始日期
// - 原因必填，最少 10 字

import { z } from "zod";

export const LEAVE_TYPES = ["sick", "personal", "family", "other"] as const;

export const leaveRequestSchema = z
  .object({
    childId: z.string().min(1, "请选择子女"),
    type: z.enum(LEAVE_TYPES, { message: "请选择请假类型" }),
    startDate: z.string().min(1, "请选择开始日期"),
    endDate: z.string().min(1, "请选择结束日期"),
    reason: z
      .string()
      .min(10, "请假原因至少 10 个字")
      .max(500, "请假原因不超过 500 个字"),
  })
  .refine((data) => data.endDate >= data.startDate, {
    message: "结束日期不能早于开始日期",
    path: ["endDate"],
  });

export type LeaveRequestFormValues = z.infer<typeof leaveRequestSchema>;
