metis-desk/modules/companies/src/api/domain/telework-authorization-values.ts
2026-10-10 12:01:58 +02:00

23 lines
660 B
TypeScript

import { z } from "zod/v4";
export const TeleworkAuthorizationInputSchema = z
.strictObject({
personId: z.uuid(),
active: z.boolean(),
startsOn: z.iso.date().nullable(),
expiresOn: z.iso.date().nullable(),
notes: z.string().trim().max(4000).nullable(),
})
.refine((value) => !(value.startsOn && value.expiresOn) || value.startsOn <= value.expiresOn, {
path: ["expiresOn"],
message: "INVALID_REQUEST",
});
export type TeleworkAuthorizationInput = z.infer<typeof TeleworkAuthorizationInputSchema>;
export class TeleworkAuthorizationError extends Error {
constructor(public readonly code: string) {
super(code);
}
}