cal.pub0.org/lib/validations/availability.ts

25 lines
775 B
TypeScript
Raw Normal View History

import { withValidation } from "next-validations";
import { z } from "zod";
import { _AvailabilityModel as Availability } from "@calcom/prisma/zod";
2022-03-30 12:17:55 +00:00
2022-04-24 00:10:32 +00:00
export const schemaAvailabilityBaseBodyParams = Availability.pick({ userId: true, eventTypeId: true, days: true }).partial();
export const schemaAvailabilityPublic = Availability.omit({});
const schemaAvailabilityRequiredParams = z.object({
2022-04-24 00:10:32 +00:00
startTime: z.date().or(z.string()).optional(),
endTime: z.date().or(z.string()).optional(),
days: z.any().optional(),
});
export const schemaAvailabilityBodyParams = schemaAvailabilityBaseBodyParams.merge(
schemaAvailabilityRequiredParams
);
export const withValidAvailability = withValidation({
schema: schemaAvailabilityBodyParams,
type: "Zod",
mode: "body",
});