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