Viewing File: /home/ubuntu/efiexchange-node-base/src/schemas/admin.schema.ts

import { object, string, TypeOf } from "zod";
export const CreateAdminSchema = object({
  body: object({
    name: string({
      required_error: "The name is required",
    }),
    email: string({ required_error: "The email is required" }).email(
      "Please enter valid email address"
    ),
    password: string({ required_error: "The password is required" }).min(
      6,
      "The entered password is too short"
    ),
    passwordConfirmation: string({
      required_error: "The confirm password is required",
    }),
  }).refine((data) => data.password === data.passwordConfirmation, {
    message: "The password doesn't match",
    path: ["passwordConfirmation"],
  }),
});

export type createAdminInput = Omit<
  TypeOf<typeof CreateAdminSchema>,
  "body.passwordConfirmation"
>;
Back to Directory File Manager