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

this.$validator.validateAll() not working correctly, always submitting form #592

Closed
wa05 opened this issue Jun 23, 2017 · 10 comments
Closed
Labels
📚 docs documentation related ❔ question More of an inquiry than an issue

Comments

@wa05
Copy link

wa05 commented Jun 23, 2017

Versions:

  • VueJs: 2.1.10
  • Vee-Validate: 2.0.0-rc.6

Description:

Submitting form with errors pass the validation, executes the .then() from the promise..

Going back to rc4

@pavel-mironchik
Copy link

Do you check the result of validation within .then() like it is described in rc6 comment?

@logaretm
Copy link
Owner

logaretm commented Jun 23, 2017

Unfortunately there was a breaking change introduced in rc6 which is explained in detail over there on the releases page, the docs hasn't been updated yet to reflect those changes.

@RoopKumar-treselle
Copy link

When I expect the new updated documentation or Alternative way to achieve the same behavior

@logaretm logaretm added 📚 docs documentation related ❔ question More of an inquiry than an issue labels Jun 23, 2017
@alejosv
Copy link

alejosv commented Jun 24, 2017

Same behavior

@qiuling2014
Copy link

mmp

@clecocq
Copy link

clecocq commented Jun 24, 2017

same issue here

@clecocq
Copy link

clecocq commented Jun 24, 2017

Ok I found this in the release comments

this.$validator.validateAll(result => {
if (! result) {
// handle input errors.
return;
}

// submit the form or whatever.
}).catch(() => {
// this is an actual app logic error.
});

However the code doesn't seem to work by my side (nothing happen)

@clecocq
Copy link

clecocq commented Jun 24, 2017

Ok I got it working

this.$validator.validateAll().then((result) => {
if(!result){
alert('error');
return;
}
alert('success');
}).catch(() => {
});

@logaretm
Copy link
Owner

@clecocq Thanks for pointing that out, there was a mistake in release notes that was fixed now.

@CindyConway
Copy link

I had an issue with running validateAll() with a complex component: a combobox that converts entries into chips. If I entered a value into the combo, then clicked save (without the combo first losing focus), validateAll returned the incorrect value because the execution of the combobox didn't complete before the validate. I wrapped the whole thing in setTimeout to push validateAll to the bottom of the call stack, then everything was ok:
setTimeout(() => { // setTimeout allows execution of the combo box for the 'to' field to complete before validation runs this.$validator.validateAll() .then((results) => { if (results) { this.$emit('someEvent', this.something); } else { this.showErrors = true; } }); }, 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 docs documentation related ❔ question More of an inquiry than an issue
Projects
None yet
Development

No branches or pull requests

8 participants