GoldStrikeArch
Explore posts from serversTTCTheo's Typesafe Cult
•Created by GoldStrikeArch on 11/3/2023 in #questions
Zod validation with react-hook-form
Is there a way to validate form field for multiple errors simultaneosly? My use case is password strength indicator where I need to validate password for 3 validation criteria (length, contains digit, contains special symbol) at the same time. I am using zod and my schema is like this:
But the problem is that I am only getting 1 error at a time (in react-hook-forms
form.formState.errors
) as I defined above. I tried to use z.union
and even z.superRefine
but to no avail.12 replies