Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I validate an entire array? #487

Open
alex-dow opened this issue Jun 6, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@alex-dow
Copy link

commented Jun 6, 2019

Example:

https://jsfiddle.net/v0s7g98k/

What I need to do is pass an entire array to a backend server to be validated, but my approach to this problem does not work as you can see from the example above. When making changes to the form elements, my custom validator is not called even though I'm managing $reset and $touch myself.

@dobromir-hristov

This comment has been minimized.

Copy link
Contributor

commented Jun 10, 2019

The way you have it setup, your async validator will only be run when you replace the whole array. This will most likely be the case if you extract your inputs into smaller vue components, and use a simple index replacement mechanism. This be it a but more verbose to write, will help make your template a bit more cleaner. However the sub components will need to emit their changes, rather directly v-model'ing the prop.
Sorry, but this is a limitation of the validation reactivity detection, it does not work such inner modifications.

@alex-dow

This comment has been minimized.

Copy link
Author

commented Jun 12, 2019

In my example above, I am manually managing state by calling $touch() and $reset(). As I understand it, if I call $touch() on a field, the validators for that field would be triggered once, and won't be triggered again until I call $reset() and $touch() again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.