2022-04-03 15:47:18 +00:00
|
|
|
import { withValidation } from "next-validations";
|
|
|
|
import { z } from "zod";
|
2022-04-02 01:51:33 +00:00
|
|
|
|
2022-04-03 15:47:18 +00:00
|
|
|
import { _ModelModel as Model } from "@calcom/prisma/zod";
|
2022-04-02 01:51:33 +00:00
|
|
|
|
2022-04-03 15:47:18 +00:00
|
|
|
export const schemaModelBaseBodyParams = Model.omit({ id: true, userId: true, createdAt: true }).partial();
|
2022-04-02 01:51:33 +00:00
|
|
|
|
2022-04-03 15:47:18 +00:00
|
|
|
const schemaModelRequiredParams = z.object({
|
|
|
|
email: z.string().email(),
|
|
|
|
});
|
2022-04-02 01:51:33 +00:00
|
|
|
|
2022-04-03 15:47:18 +00:00
|
|
|
export const schemaModelBodyParams = schemaModelBaseBodyParams.merge(schemaModelRequiredParams);
|
2022-04-02 01:51:33 +00:00
|
|
|
|
2022-04-03 15:47:18 +00:00
|
|
|
export const schemaModelPublic = Model.omit({
|
|
|
|
id: true,
|
|
|
|
userId: true,
|
|
|
|
});
|
2022-04-02 01:51:33 +00:00
|
|
|
|
2022-04-03 15:47:18 +00:00
|
|
|
export const withValidModel = withValidation({
|
|
|
|
schema: schemaModelBodyParams,
|
|
|
|
type: "Zod",
|
|
|
|
mode: "body",
|
|
|
|
});
|