FIxes in async validations (in sync case), closes 214

This commit is contained in:
Anatoliy Chakkaev 2013-03-01 21:13:04 +07:00
parent ded757bd50
commit 358f7b788c
1 changed files with 6 additions and 3 deletions

View File

@ -351,12 +351,16 @@ Validatable.prototype.isValid = function (callback) {
}); });
this.trigger('validation', function (validationsDone) { this.trigger('validation', function (validationsDone) {
var inst = this; var inst = this,
asyncFail = false;
this.constructor._validations.forEach(function (v) { this.constructor._validations.forEach(function (v) {
if (v[2] && v[2].async) { if (v[2] && v[2].async) {
async = true; async = true;
wait += 1; wait += 1;
validationFailed(inst, v, done); process.nextTick(function () {
validationFailed(inst, v, done);
});
} else { } else {
if (validationFailed(inst, v)) { if (validationFailed(inst, v)) {
valid = false; valid = false;
@ -369,7 +373,6 @@ Validatable.prototype.isValid = function (callback) {
validationsDone(); validationsDone();
} }
var asyncFail = false;
function done(fail) { function done(fail) {
asyncFail = asyncFail || fail; asyncFail = asyncFail || fail;
if (--wait === 0 && callback) { if (--wait === 0 && callback) {