From 5dd62e28365d1f889824f83153ca1af307036cca Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 14 Jun 2020 01:45:23 +0200 Subject: [PATCH] Add callIfNull support --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index f4f6681..9a235f1 100644 --- a/index.js +++ b/index.js @@ -3,9 +3,13 @@ const combinator = require("@validatem/combinator"); module.exports = function withContext(rules, context) { - return combinator((item, applyValidators, parentContext) => { + let validator = combinator((item, applyValidators, parentContext) => { let mergedContext = Object.assign({}, parentContext, context); return applyValidators(item, rules, mergedContext); }); + + validator.callIfNull = true; + + return validator; };