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