Skip to content

fromMaybe

fromMaybe<E>(onNone): <A>(maybe) => Validation<E, A>

Defined in: Core/Validation.ts:119

Creates a Validation from a Maybe. If the Maybe is None, returns Failed with the error from onNone. Otherwise, returns Passed.

E

() => E

<A>(maybe) => Validation<E, A>

pipe(Maybe.none(), Validation.fromMaybe(() => "is none")); // Failed(["is none"])
pipe(Maybe.some(42), Validation.fromMaybe(() => "is none")); // Passed(42)