runRules method

Object? runRules(
  1. Object? output,
  2. int issuesBefore,
  3. ParseState state,
  4. List<Object> path,
)
inherited

Run rules on output. Skipped when the value already has issues.

Implementation

Object? runRules(
  Object? output,
  int issuesBefore,
  ParseState state,
  List<Object> path,
) {
  if (output is Invalid || output is Undefined) {
    return output;
  }
  if (state.issues.length > issuesBefore) {
    return output;
  }
  O typed = output as O;
  for (Rule<O> rule in rules) {
    if (!rule.apply(
          typed,
          RuleContext(state: state, path: path, value: typed),
        ) &&
        bails) {
      break;
    }
  }
  return typed;
}