filterOrFail method

ZIO<R, E, A> filterOrFail(
  1. bool predicate(
    1. A _
    ),
  2. E onFalse(
    1. A _
    )
)

Filters the success value of this ZIO with the given predicate, failing with onFalse if the predicate fails.

Implementation

ZIO<R, E, A> filterOrFail(
  bool Function(A _) predicate,
  E Function(A _) onFalse,
) =>
    flatMapEither((a) => Either.fromPredicate(a, predicate, onFalse));