-
-
Notifications
You must be signed in to change notification settings - Fork 196
Description
Version Number
5.1.1
Codesandbox/Expo snack
https://codesandbox.io/p/devbox/eager-sun-jt4df-82ptws
Steps to reproduce
- open the console in the preview
- Submit the form
- See error
- to make the error goes array, uncomment the line 56
When using Zod resolver and nested discriminated unions, the resolver is not validating the required field before trying to execute the nested discriminated union validations, leaving the error message below:
Uncaught TypeError: Cannot read properties of undefined (reading '0')
Using the @hookform/resolvers/standard-schema
works as expected. It validates if the nested discriminated field is filled before going to its validation. But the errors type returns blank as shown in the print below (not sure if this is another bug or expected), and I use it to have a custom map error (z.setErrorMap).

Expected behaviour
work as the parent/root discriminatedUnion, returning the error type invalid_union_discriminator for the field when is not selected
What browsers are you seeing the problem on?
Chrome
Relevant log output
Uncaught TypeError: Cannot read properties of undefined (reading '0')
Code of Conduct
- I agree to follow this project's Code of Conduct