You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
378 B
JavaScript
16 lines
378 B
JavaScript
"use strict";
|
|
|
|
const combinator = require("@validatem/combinator");
|
|
|
|
module.exports = function withContext(rules, context) {
|
|
let validator = combinator((item, applyValidators, parentContext) => {
|
|
let mergedContext = Object.assign({}, parentContext, context);
|
|
|
|
return applyValidators(item, rules, mergedContext);
|
|
});
|
|
|
|
validator.callIfNull = true;
|
|
|
|
return validator;
|
|
};
|