0

In Joi you can do is_email_verified: Joi.forbidden().default(false). This prevents is_email_verified from being present when validating but afterwards it will add in the property with the default value.

In zod I want to do the same thing e.g.

export const register = z.object({
  email: z.string().email(),
  password: z.string().superRefine(password),
  first_name: z.string(),
  last_name: z.string(),
  is_email_verified: z.boolean().default(false)
});

I want is_email_verified to not be allowed to be in the object initially but added after with the default value of false.

I thought about transforming the object and adding it but I couldn't get it to work with correct types.

Any idea on what I can do?

OultimoCoder
  • 244
  • 2
  • 7
  • 24

0 Answers0