Nested Schema failures do not show in field #4027
Replies: 2 comments
-
Or differently put, how can I make a field invalid where the properties throwing errors? I cannot pick the name of the path of the property that raises the error because then it is missing in values. |
Beta Was this translation helpful? Give feedback.
-
I would say it is intended. It wasn't accounted for in implementation since fields must have a visual representation for the user. Mostly this works fine until you have rules validating the structure itself and not the individual value or like your case, a field is a container object. I have yet to figure out how to handle this since errors are path based. The only workaround is to recreate your fields in a way that each validatable property that will show errors is a field managed by vee-validate. Alternatively, you can get the error yourself from I plan to tackle this but have no ETA for it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@logaretm Is this a bug or a feature? If I have a nested object as field and I have an according zod schema for that field and a schema for the whole form it is possible I get errors on nested values like
someobject.somenumber: "Number must be greater than 0"
the path is thensomeobject.somenumber
but in the code below the fieldId is matched to the path, but since onlysombeobject
is the fieldId there will be no match forsomeobject.somenumber
and hence, the field will identify as valid but if some of its properties are not valid so should the field itself.Is there a way to either have some kind of aggregated path that includes the parent or flatten the path to the parent or something to get a match?
vee-validate/packages/vee-validate/src/useForm.ts
Line 197 in 31b4775
Beta Was this translation helpful? Give feedback.
All reactions