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

22 lines
599 B
TypeScript
Raw Normal View History

import { withValidation } from "next-validations";
2022-04-01 23:55:41 +00:00
import { z } from "zod";
import { _ScheduleModel as Schedule } from "@calcom/prisma/zod";
2022-04-01 23:55:41 +00:00
const schemaScheduleBaseBodyParams = Schedule.omit({ id: true }).partial();
const schemaScheduleRequiredParams = z.object({
userId: z.number(),
name: z.string(),
});
export const schemaScheduleBodyParams = schemaScheduleBaseBodyParams.merge(schemaScheduleRequiredParams);
export const schemaSchedulePublic = Schedule.omit({});
export const withValidSchedule = withValidation({
schema: schemaScheduleBodyParams,
type: "Zod",
mode: "body",
});