Closed
Description
I'm struggling to reimplement the conditional validators described here using the validator mapper in my own codebase. It would be nice to have an evaluateCondition
that would just give me true or false without passing any context inside:
import { validatorMapper, evaluateCondition } from '@@ddf';
const decorate = fn => ({ condition, ...rest }) => {
if (!evaluateCondition) return true;
return fn(rest);
}
const myValidatorMapper = Object.keys(validatorMapper).reduce((obj, key) => ({
...obj,
[key]: decorate(validatorMapper[key]),
}) ,{});