Replies: 1 comment
-
Zod's union implementation is not smart enough to differentiate two schemas automatically at the moment. What you are looking for is z.discriminatedUnion('type', [SimpleSchema, AgeSchema]) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug and the expected behavior
When using client-side form validation with Conform, Zod and Remix with a Discriminated Union Type, I get an unclear error : "Invalid input".
Demo in this stackblitz
Here is a simple repro :
Here is an example object output of the failed validation :
We do not know "which" property triggered the error, which property is missing and overriding the error message to better identify the source does not seem to be working.
This is specific to client-side validation, as server-side validation works.
Expected behavior :
Conform version
v1.1.5
Steps to Reproduce the Bug or Issue
What browsers are you seeing the problem on?
Chrome
Screenshots or Videos
No response
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions