Pass path to custom merger functions as well

master
Sven Slootweg 4 years ago
parent ff2af85fb1
commit 8f70301fb6

@ -14,6 +14,9 @@ const wrapPath = require("@validatem/wrap-path");
/* NOTE: In some cases below, we explicitly check for `undefined` only, rather than for both `undefined` and `null`. This is to allow explicitly overriding existent values with `null` during a merge. */
// FIXME: Prevent prototype pollution
// FIXME: Figure out an ergonomic way to do nested array merging (ie. flattening)
function wrapValidationPath(basePathSegments, lastProperty, rules) {
let combinedPath = basePathSegments.concat(virtualProperty(lastProperty));
@ -85,7 +88,7 @@ function mergeValue(rule, a, b, path) {
} else if (b === undefined) {
return a;
} else {
return rule(a, b);
return rule(a, b, path);
}
} else if (typeof rule === "object") {
if (Array.isArray(rule)) {

Loading…
Cancel
Save