Skip to content

fromNullable

fromNullable<E>(onNull): <A>(value) => Validation<E, A>

Defined in: Core/Validation.ts:105

Creates a Validation from a nullable value. If the value is null or undefined, returns Failed with the error from onNull. Otherwise, returns Passed.

E

() => E

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

pipe(null, Validation.fromNullable(() => "is null")); // Failed(["is null"])
pipe(42, Validation.fromNullable(() => "is null"));   // Passed(42)