Add callIfNull support
This commit is contained in:
parent
0d7f280311
commit
cb16313b03
6
index.js
6
index.js
|
@ -20,7 +20,7 @@ function concat(arrays) {
|
|||
module.exports = function wrapError(message, rules, options = {}) {
|
||||
let preserveOriginalErrors = defaultValue(options.preserveOriginalErrors, false);
|
||||
|
||||
return combinator((value, applyValidators, context) => {
|
||||
let validator = combinator((value, applyValidators, context) => {
|
||||
let result = applyValidators(value, rules, context);
|
||||
|
||||
if (result.errors.length > 0) {
|
||||
|
@ -76,4 +76,8 @@ module.exports = function wrapError(message, rules, options = {}) {
|
|||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
validator.callIfNull = true;
|
||||
|
||||
return validator;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue