validate method

bool validate(
  1. Map<String, dynamic> input,
  2. String expression
)

Implementation

bool validate(Map<String, dynamic> input, String expression) {
  ExpressionLanguage expressionLanguage =
      ExpressionLanguage.fromJson(json.decode(expression));
  bool isOrValid = false;
  if (expressionLanguage.or.isNotEmpty) {
    for (var element in expressionLanguage.or) {
      if (input.containsKey(element.id)) {
        if (element.expression == "IS_NOT_EMPTY") {
          if (input[element.id] != null &&
              cast<String>(input[element.id])!.isNotEmpty) {
            isOrValid = true;
            break;
          }
        }
      }
    }
  }
  if (!isOrValid) {
    error = expressionLanguage.orValidationMessage ?? "";
  }
  return isOrValid;
}