|
|
@ -3,13 +3,9 @@ |
|
|
|
const combinator = require("@validatem/combinator"); |
|
|
|
|
|
|
|
module.exports = function withContext(rules, context) { |
|
|
|
let validator = combinator((item, applyValidators, parentContext) => { |
|
|
|
return combinator((item, applyValidators, parentContext) => { |
|
|
|
let mergedContext = Object.assign({}, parentContext, context); |
|
|
|
|
|
|
|
return applyValidators(item, rules, mergedContext); |
|
|
|
}); |
|
|
|
|
|
|
|
validator.callIfNull = true; |
|
|
|
|
|
|
|
return validator; |
|
|
|
}; |
|
|
|