Skip to content

recoverUnless

recoverUnless<E, A, B>(isBlocked, fallback): (data) => Validation<E, A | B>

Defined in: Core/Validation.ts:278

Recovers from a Failed state unless isBlocked returns true for any of the accumulated errors. The fallback can produce a different success type, widening the result to Validation<E, A | B>.

E

A

B

(e) => boolean

() => Validation<E, B>

(data) => Validation<E, A | B>

pipe(
  Validation.failed("field-error"),
  Validation.recoverUnless(e => e === "fatal", () => Validation.passed(0))
); // Passed(0)