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

37 lines
842 B
TypeScript
Raw Normal View History

import { withValidation } from "next-validations";
import { z } from "zod";
2022-03-30 12:17:55 +00:00
import { _UserModel as User } from "@calcom/prisma/zod";
export const schemaUserBaseBodyParams = User.omit({
2022-03-30 12:17:55 +00:00
id: true,
createdAt: true,
password: true,
twoFactorEnabled: true,
twoFactorSecret: true,
}).partial();
2022-03-30 12:17:55 +00:00
const schemaUserRequiredParams = z.object({
email: z.string().email(),
});
export const schemaUserBodyParams = schemaUserBaseBodyParams.merge(schemaUserRequiredParams);
2022-03-30 12:17:55 +00:00
export const schemaUserPublic = User.omit({
identityProvider: true,
identityProviderId: true,
plan: true,
metadata: true,
password: true,
twoFactorEnabled: true,
twoFactorSecret: true,
trialEndsAt: true,
completedOnboarding: true,
});
export const withValidUser = withValidation({
schema: schemaUserBodyParams,
type: "Zod",
mode: "body",
});