You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on a project where I use zod to create and validate form schemas. My forms can have different fields as well as different validation rules, depending on the value of a preceding field.
In this specific case, depending on the value of FieldA(), either FieldB() and FieldC() or FieldD() and FieldE() will be shown.
However, I'm encountering an issue where validation only seems to work for FieldA(), FieldB(), and FieldC(). If the value of FieldA() is set to hide FieldB() and FieldC(), as expected, FieldD() and FieldE() are displayed. Unfortunately, validation doesn't seem to occur for these fields.
Is there a solution or workaround that would allow me to dynamically validate these fields based on the conditions I have set? Any insights or suggestions would be greatly appreciated.
I ran into this issue as well for a project I'm working on. I'm interested in contributing a fix, cool if I pick this up, @pablo-abc?
I did some testing already -- a union Zod issue has nested issues under a unionErrors property. It also has an empty path, which is why the validator is currently skipping it. I'm planning to update validateSchema/shapeErrors to check the issue code for 'invalid_union' and surface its nested issues as part of the AssignableErrors that's returned from validate.
Describe the bug
Hello,
I'm currently working on a project where I use zod to create and validate form schemas. My forms can have different fields as well as different validation rules, depending on the value of a preceding field.
Here's an illustration of the code I'm using:
In this specific case, depending on the value of
FieldA()
, eitherFieldB()
andFieldC()
orFieldD()
andFieldE()
will be shown.However, I'm encountering an issue where validation only seems to work for
FieldA()
,FieldB()
, andFieldC()
. If the value ofFieldA()
is set to hideFieldB()
andFieldC()
, as expected,FieldD()
andFieldE()
are displayed. Unfortunately, validation doesn't seem to occur for these fields.Is there a solution or workaround that would allow me to dynamically validate these fields based on the conditions I have set? Any insights or suggestions would be greatly appreciated.
Best Regards,
Jérémy
Which package/s are you using?
@felte/solid (SolidJS), @felte/reporter-solid, @felte/validator-zod
Environment
Version:
To reproduce
No response
Small reproduction example
No response
Screenshots
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: