|
|
@ -5,9 +5,13 @@ const combinator = require("@validatem/combinator");
|
|
|
|
// TODO: Document that this *exposes* context
|
|
|
|
// TODO: Document that this *exposes* context
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function dynamic(ruleGenerationFunction) {
|
|
|
|
module.exports = function dynamic(ruleGenerationFunction) {
|
|
|
|
return combinator((value, applyValidators, context) => {
|
|
|
|
let validator = combinator((value, applyValidators, context) => {
|
|
|
|
let rules = ruleGenerationFunction(value, context);
|
|
|
|
let rules = ruleGenerationFunction(value, context);
|
|
|
|
|
|
|
|
|
|
|
|
return applyValidators(value, rules);
|
|
|
|
return applyValidators(value, rules);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
validator.callIfNull = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return validator;
|
|
|
|
};
|
|
|
|
};
|
|
|
|