Conditional zod schema on onSubmit form validator
export const createEmployeeSchema = z.object({
email: z.string().email(),
password: z.string().min(8),
firstName: z.string().min(2),
});
export const updateEmployeeSchema = createEmployeeSchema.omit({
password: true
});
and on the form do something like this
Since not much changes besides the password field (which is removed in update form), I'd rather share the same form component
But then on my password form.Field I get this typescript error when trying to render the errors for that field because the error object is unknown
