Add a global "no heuristics" flag for validator debugging

pull/4/head
Sven Slootweg 4 years ago
parent 3298399243
commit d610cad10b

@ -12,7 +12,12 @@ module.exports = function applyValidators(value, rules, context = {}) {
let normalizedRules = normalizeRules(rules, { normalizeObjects: true });
let validator = composeRules.compose(normalizedRules);
let { errors, newValue } = validator(value, context);
// FIXME: Document this option!
let finalContext = (process.env.VALIDATEM_NO_HEURISTICS === "1")
? { ...context, __validatemNoHeuristics: true }
: context;
let { errors, newValue } = validator(value, finalContext);
// NOTE: We mutate the error here, because Error objects are not safely cloneable
for (let error of errors) {

Loading…
Cancel
Save