What happened?
When using a validation schema in combination with useField components (such as <Field />), the validation results for currently not-rendered components are contained within errors and errorBag. As soon as they are rendered, the errors disappear.
My expectation would be that the rendering state of components has no impact on the validation results, which means there shouldn't be any errors until the user has interacted with the form.
Potential fix
I dug into the code and found out that it is probably an easy fix in useForms. The exit for not-rendered components needs to be after the two mode-specific exits (silent and `validated-only).
I would have opened a PR, but as per the Contribution Guide I created this issue first. Once I have the OK I can open a PR, just let me know
Reproduction steps
- Open the provided Stackblitz repro (an example from the docs just slightly modified)
- Click the `Toggle form button
- You will see the errors being filled while the form is hidden
Version
Vue.js 3.x and vee-validate 4.x
Demo link
https://stackblitz.com/edit/qklfvbys?file=src%2FApp.vue
Code of Conduct
What happened?
When using a validation schema in combination with
useFieldcomponents (such as<Field />), the validation results for currently not-rendered components are contained withinerrorsanderrorBag. As soon as they are rendered, the errors disappear.My expectation would be that the rendering state of components has no impact on the validation results, which means there shouldn't be any errors until the user has interacted with the form.
Potential fix
I dug into the code and found out that it is probably an easy fix in
useForms. The exit for not-rendered components needs to be after the two mode-specific exits (silentand `validated-only).I would have opened a PR, but as per the Contribution Guide I created this issue first. Once I have the OK I can open a PR, just let me know
Reproduction steps
Version
Vue.js 3.x and vee-validate 4.x
Demo link
https://stackblitz.com/edit/qklfvbys?file=src%2FApp.vue
Code of Conduct