From 8f70301fb6f18e71ed3a9e1b649ba0cea0779719 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Tue, 8 Sep 2020 16:31:38 +0200 Subject: [PATCH] Pass path to custom merger functions as well --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 900a40a..4b1fdd7 100644 --- a/index.js +++ b/index.js @@ -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)) {