Add callIfNull support
This commit is contained in:
parent
7183050d1e
commit
ddeeb380a7
6
index.js
6
index.js
|
@ -5,9 +5,13 @@ const combinator = require("@validatem/combinator");
|
|||
// TODO: Document that this *exposes* context
|
||||
|
||||
module.exports = function dynamic(ruleGenerationFunction) {
|
||||
return combinator((value, applyValidators, context) => {
|
||||
let validator = combinator((value, applyValidators, context) => {
|
||||
let rules = ruleGenerationFunction(value, context);
|
||||
|
||||
return applyValidators(value, rules);
|
||||
});
|
||||
|
||||
validator.callIfNull = true;
|
||||
|
||||
return validator;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue