at<S, T> static method

Validator<S> at<S, T>(
  1. Selector<S, T> selector, {
  2. required Validator<T> validator,
})

Creates a validator on S by applying a validator on a subfield of S.

Implementation

static Validator<S> at<S, T>(
  Selector<S, T> selector, {
  required Validator<T> validator,
}) {
  return (S subject) {
    final field = selector(subject);
    return validator(field).fold((l) => Left(l), (_) => Right(subject));
  };
}