26 lines
756 B
TypeScript
26 lines
756 B
TypeScript
import { z } from "zod";
|
|
import { VacationType } from "../types/enums.js";
|
|
|
|
export const CreateVacationSchema = z
|
|
.object({
|
|
resourceId: z.string(),
|
|
type: z.nativeEnum(VacationType),
|
|
startDate: z.coerce.date(),
|
|
endDate: z.coerce.date(),
|
|
note: z.string().max(500).optional(),
|
|
})
|
|
.refine((d) => d.endDate >= d.startDate, {
|
|
message: "End date must be after start date",
|
|
path: ["endDate"],
|
|
});
|
|
|
|
export type CreateVacationInput = z.infer<typeof CreateVacationSchema>;
|
|
|
|
export const UpdateVacationStatusSchema = z.object({
|
|
id: z.string(),
|
|
status: z.enum(["APPROVED", "REJECTED", "CANCELLED"]),
|
|
note: z.string().max(500).optional(),
|
|
});
|
|
|
|
export type UpdateVacationStatusInput = z.infer<typeof UpdateVacationStatusSchema>;
|