async-validator
Advanced tools
Comparing version 1.7.1 to 1.8.0
@@ -168,3 +168,3 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
if ((options.first || options.fieldFirst) && errors.length) { | ||
if (options.first && errors.length) { | ||
errorFields[rule.field] = 1; | ||
@@ -217,3 +217,10 @@ return doIt(errors); | ||
rule.validator(rule, data.value, cb, data.source, options); | ||
var res = rule.validator(rule, data.value, cb, data.source, options); | ||
if (res && res.then) { | ||
res.then(function () { | ||
return cb(); | ||
}, function (e) { | ||
return cb(e); | ||
}); | ||
} | ||
}, function (results) { | ||
@@ -220,0 +227,0 @@ complete(results); |
# History | ||
---- | ||
## 1.8.0 / 2017-08-16 | ||
- validator support return promise. | ||
## 1.7.0 / 2017-06/09 | ||
@@ -4,0 +9,0 @@ |
@@ -186,3 +186,3 @@ 'use strict'; | ||
if ((options.first || options.fieldFirst) && errors.length) { | ||
if (options.first && errors.length) { | ||
errorFields[rule.field] = 1; | ||
@@ -235,3 +235,10 @@ return doIt(errors); | ||
rule.validator(rule, data.value, cb, data.source, options); | ||
var res = rule.validator(rule, data.value, cb, data.source, options); | ||
if (res && res.then) { | ||
res.then(function () { | ||
return cb(); | ||
}, function (e) { | ||
return cb(e); | ||
}); | ||
} | ||
}, function (results) { | ||
@@ -238,0 +245,0 @@ complete(results); |
{ | ||
"name": "async-validator", | ||
"version": "1.7.1", | ||
"version": "1.8.0", | ||
"description": "validate form asynchronous", | ||
@@ -47,2 +47,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"coveralls": "^2.13.1", | ||
"jest": "20.x", | ||
@@ -49,0 +50,0 @@ "pre-commit": "1.x", |
@@ -323,3 +323,3 @@ # async-validator | ||
```js | ||
{ | ||
const fields = { | ||
asyncField:{ | ||
@@ -336,4 +336,13 @@ validator(rule,value,callback){ | ||
} | ||
} | ||
} | ||
}, | ||
promiseField:{ | ||
validator(rule, value){ | ||
return ajax({ | ||
url:'xx', | ||
value:value | ||
}); | ||
} | ||
} | ||
}; | ||
``` | ||
@@ -340,0 +349,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95992
2342
366
4