-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ValidationObserver should also expose fields
in addition to errors
.
#2484
Comments
That's a good use-case. I think it should be trivial to implement such a feature, will check it out tonight. |
So is it trivial on a closer look as well? |
Yea, but I'm thinking about its type, like a |
What would be the benefits of the Boolean? |
I'm looking for this: booleans <ValidationObserver v-slot="{ fields }">
<p v-if="fields.name">Please Correct the Field name</p>
</ValidationValidation> array of strings <ValidationObserver v-slot="{ fields }">
<p v-if="fields.length">Please correct the {{ fields[0] }} field</p>
</ValidationValidation> The array looks nicer in that exact case, but consider this one: array of strings <ValidationObserver v-slot="{ fields }">
<p v-if="fields.includes('name')">Please Correct the Field name</p>
</ValidationValidation> Which is not useful if you need access to specific fields. Feel free to suggest more formats/types. |
I actually have run into the case where all the VPs are in one area, but specific icons need to go in a different area to represent different errors. Thus, in my use-case, having a VO fields that looked like an Object with keys being the VP vid and the values being the VP's failedRules would be most helpful:
|
@ryleyb That sounds good but because observers can be nested, it makes it hard to make a predictable structure. Either nested observers should be removed (which I'm leaning towards) since there isn't a single use-case that justifies it so far. |
This is finally implemented here #2535 would love some comments before I can merge for |
@logaretm The feature would be very handy, and the implementation looks solid to me. I'd like to see this merged and 3.2 released 👍 |
* chore: upgrade dependencies * feat: added fields slot prop to the observer closes #2484
Form validation progress was easy-to-achieve in Vee-Validate 2, since it exposed
this.fields
.But in Vee-Validate 3, ValidationObserver only exposes
errors
. The problem is it does not reflect the invalidity of a required field while it has not been touched yet.This makes it near impossible to observe the individual fields' validity without recollecting the state from each component manually, which should be the work of ValidationObserver.
ValidationObserver should also expose
fields
in addition toerrors
in order to achieve form validation progress as shown in the following gif:The text was updated successfully, but these errors were encountered: