Closed erguotou520 closed 8 years ago
In current version, The $validate
don't return the promise
. However, You can use the cb
argument.
See the document.
http://vuejs.github.io/vue-validator/en/api.html#validate-field-touched-cb-
(sorry, bad sample ...)
the below demo (fork the your demo and updated): https://jsfiddle.net/kazupon/7pxyayqj/2/
Ok, got it. The cb
did the same. I didn't see this argument before....
vue & vue-validator version
1.0.24, 2.1.3
Steps to reproduce
js function save() { this.$validate(true); if (this.$validation.valid) { // do save } }
What is Expected?
Can't save the form because there is a field that is invalid.
What is actually happening?
Success post the save data because the invalid field needs async validate, when click the save button, the async result not returned.
JSFiddle
A demo here https://jsfiddle.net/k0h3m8aq/1/ Typed something, blur, then type
unique
, clicksave
button quickly, nothing. Wait for a while, click button, the alert shows.My puzzle
The
$validate
returnsundefined
, so it's sync, this makes the question. Can it return apromise
so I can submit the form afterresolve
? Or? There is no need to do unique validation in this case? Do it in backend?