How do I merge two Zod schemas?
Hey guys, I am creating a form with react-hook-form and Zod. The form was too long, so I decided to divide it into multi step form, with each step having separate Zod schema. I am storing the form data locally until all steps are complete. Now, I want a Zod schema for combining the schemas and perform a validation before I send the data to the server. I am unable to find the right solution. Can somebody please help me?
4 Replies
Solution
Would this work for you?
maybe this helps?
soo valid object are either:
Thanks, this helped. I was looking into the docs for union, intersection, etc. and did not check for
and
method 😓