initail work on paid booking, improve validations

This commit is contained in:
Agusti Fernandez Pardo committed 2022-04-01 17:53:52 +02:00
1 parent 12de89294d
commit e284707250
14 files changed
+103 -42

No files matched your search

+13 -1
View File
@@ -1,8 +1,20 @@
import { withValidation } from "next-validations";
import { z } from "zod";
import { _BookingModel as Booking } from "@calcom/prisma/zod";
export const schemaBookingBodyParams = Booking.omit({ id: true });
// Here we remove any parameters that are not needed for the API with omit.
const schemaBookingBaseBodyParams = Booking.omit({ id: true }).partial();
// Here we redeclare the required ones after removing the ones we don't need.
// and making the rest optional with .partial()
const schemaBookingRequiredParams = z.object({
uid: z.string(),
title: z.string(),
startTime: z.date(),
endTime: z.date(),
});
export const schemaBookingBodyParams = schemaBookingBaseBodyParams.merge(schemaBookingRequiredParams);
export const schemaBookingPublic = Booking.omit({});