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

26 lines
693 B
TypeScript
Raw Normal View History

2022-03-26 21:29:30 +00:00
import { withValidation } from "next-validations";
import { z } from "zod";
const schemaBooking = z
.object({
uid: z.string().min(3),
title: z.string().min(3),
description: z.string().min(3).optional(),
startTime: z.date().or(z.string()),
endTime: z.date(),
location: z.string().min(3).optional(),
createdAt: z.date().or(z.string()),
2022-03-27 13:15:46 +00:00
updatedAt: z.date().or(z.string()),
2022-03-26 21:29:30 +00:00
confirmed: z.boolean().default(true),
rejected: z.boolean().default(false),
paid: z.boolean().default(false),
})
.strict();
2022-03-26 21:29:30 +00:00
const withValidBooking = withValidation({
schema: schemaBooking,
type: "Zod",
mode: "body",
});
export { schemaBooking, withValidBooking };