Skip to content

Making condition evaluation more generic #802

Closed
@skateman

Description

@skateman

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]),
}) ,{});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions