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.
20 lines
533 B
JavaScript
20 lines
533 B
JavaScript
4 years ago
|
"use strict";
|
||
|
|
||
|
const combinator = require("@validatem/combinator");
|
||
|
const validationResult = require("@validatem/validation-result");
|
||
|
const annotateErrors = require("@validatem/annotate-errors");
|
||
|
|
||
|
module.exports = function wrapPath(pathSegments, rules) {
|
||
|
return combinator((value, applyValidators, context) => {
|
||
|
let result = applyValidators(value, rules, context);
|
||
|
|
||
|
return validationResult({
|
||
|
newValue: result.newValue,
|
||
|
errors: annotateErrors({
|
||
|
errors: result.errors,
|
||
|
pathSegments: pathSegments
|
||
|
})
|
||
|
});
|
||
|
});
|
||
|
};
|