vee-validate
vee-validate copied to clipboard
useForm() validateField() says field does not exist Vue 3
What happened?
When I use useForm() I'm able to call validate() fine and it returns the following:
It shows I have a name and description field, but then when I call validateField('name') it says the field doesn't exist
Reproduction steps
- call useForm() with initialValues
- call validateField() on one of the fields
...
Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
- [ ] Firefox
- [X] Chrome
- [ ] Safari
- [ ] Microsoft Edge
Relevant log output
No response
Demo link
n/a
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
This might be intended if you didn't call useField for that field name. Mainly because validateField tries to search for the field instance in the form:
https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/src/useForm.ts#L481-L486
The validate method isn't the same as it validates the form values regardless of what fields were actually registered.
I will tag this as an enhancement, for now, it would be ideal to eliminate this confusion.
Closing since it is unlikely that you can validate a specific path that may represent a field or not.