check method

Validator<S> check(
  1. Predicate<S> predicate, {
  2. required dynamic error,
})

Creates a new validator that nests checks on an object field.

If both the calling validator and the additional check fail, the error produced by the calling is returned.

Implementation

Validator<S> check(Predicate<S> predicate, {required dynamic error}) {
  final Validator<S> predicateValidator =
      (S s) => predicate(s) ? Right(s) : Left([error]);
  return _join(this, predicateValidator);
}