passes method

  1. @override
String? passes(
  1. ValidationContext c
)
override

Checks the value in context: the message key or text when it fails, null when it passes.

Implementation

@override
String? passes(ValidationContext c) {
  final other = this.other;
  final excluded = switch (name) {
    'exclude_if' =>
      ValidationContext.exists(c.data, other!) &&
          _otherMatches(c, other, values),
    'exclude_unless' => !_otherMatches(c, other!, values),
    'exclude_with' => ValidationContext.exists(c.data, other!),
    'exclude_without' => isEmptyValue(c.root(other!)),
    _ => true,
  };
  return excluded ? name : null;
}