|
|
|
@ -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) {
|
|
|
|
|