From ddeeb380a7220c8a502e219c9bf243333c5a7771 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 14 Jun 2020 01:47:47 +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 e3d7a13..5482d6e 100644 --- a/index.js +++ b/index.js @@ -5,9 +5,13 @@ const combinator = require("@validatem/combinator"); // TODO: Document that this *exposes* context module.exports = function dynamic(ruleGenerationFunction) { - return combinator((value, applyValidators, context) => { + let validator = combinator((value, applyValidators, context) => { let rules = ruleGenerationFunction(value, context); return applyValidators(value, rules); }); + + validator.callIfNull = true; + + return validator; };