-
Notifications
You must be signed in to change notification settings - Fork 244
[Question] How is @on-validate supposed to work? #41
Comments
https://jsfiddle.net/bt5dhqtf/927/
It might be useful when you do the validations in some other components asynchronously like here validateSecondTab: function(){
return this.$refs.secondTabForm.validate();
},
handleValidation: function(isValid, tabIndex){
console.log('Tab: '+tabIndex+ ' valid: '+isValid)
if(!isValid){
// display something here
}
}, and maybe you want to display some notifications, alerts etc. Note that on-validated is not called if a step doesn't have a To summarize: Play around with this fiddle and maybe it will be easier to understand |
Right, it seems your example uses some sort of third-party form schema generator and validator, which upon you use the result of validate() to further propagate your handleValidation outcome. At the moment we're using bootstrap-vue (which is way awesome, one might add) to generate the forms, with Vuelidate as a validator. Unsure if the reactive validation object Vuelidate generates can be directly connected without checking each required attribute explicitly. Like so: Template Script
Methods
Which is, as the TODO clearly states, fairly unelegant. |
What about Validation groups ? |
@hydraheim Here is a basic fiddle for Vuelidate. |
Thanks for looking into that. Already looked at validation groups, but referencing the docs there doesn't seem to be any support for validating several isolated groups (which would correspond to step 1, step 2, and so on). There might be, but the docs leaves some things to be desired. |
Well I think you should have 1 group per step :) this.$v.validationGroup.$touch();
return !this.$v.validationGroup.$invalid For 2 or more you can save them in some array this.$v.validationGroup.$touch();
this.$v.validationGroup2.$touch();
return !this.$v.validationGroup.$invalid && !this.$v.validationGroup2.$invalid. Anyway, those are vuelidate specific details. Form-wizard was not built with a specific validator library in mind. It exposes the |
I made a more complete fiddle @hydraheim |
Will delve into the example once we revisit this for refactoring. Highly appreciated for the hard work here, rare for issues that reside outside the main component. This is above and beyond, sir. |
Glad I could help @hydraheim As a side note, the example from above was added to the readme. Maybe it helps other people too. Also I used bootstrap in it to keep it simpler but shouldn't be an issue. Let me know if it works out in the end and if you had to do other changes so I can update my example as well. I didn't use vuelidate too much, so I might not know the best practices for it yet. |
@cristijora - Is there any way I could please see your integration you mentioned with vee-validate? I've spent a couple of hours trying to get it to work and I'm about out of ideas :/ |
@cristijora I'm also not able to get the vue-form-wizard to work with vee-validate. The solution you mentioned would be much appreciated! |
Looking at the docs, there is very little outlining how this directive works. What does it run through and what alters its outcome? Hence:
Would always yield "isValid" as true.
Reference: https://cristijora.github.io/vue-form-wizard/#/?id=async-validation
The text was updated successfully, but these errors were encountered: