Class: Validation

lib/validation~ Validation

new Validation()

Validation[α, β] <: Applicative[β] , Functor[β] , Show , Eq

The Validation[α, β] is a disjunction that's more appropriate for validating inputs, or any use case where you want to aggregate failures. Not only does the Validation provide a better terminology for working with such cases (Failure and Success versus Failure and Success), it also allows one to easily aggregate failures and successes as an Applicative Functor.

Source:

Members

isFailure

Boolean

True if the Validation[α, β] contains a Failure value.

Source:

isSuccess

Boolean

True if the Validation[α, β] contains a Success value.

Source:

Methods

<static> Failure()

a → Validation[α, β]

Constructs a new Validation[α, β] structure holding a Failure value.

Source:

<static> fromEither()

Either[α, β] → Validation[α, β]

Constructs a new Either[α, β] structure from a Validation[α, β] type.

Source:

<static> fromNullable()

α → Validation[α, α]

Constructs a new Validation[α, β] structure from a nullable type.

Takes the Failure case if the value is null or undefined. Takes the Success case otherwise.

Source:

<static> of()

β → Validation[α, β]

Creates a new Validation[α, β] instance holding the Success value b.

b can be any value, including null, undefined or another Validation[α, β] structure.

Source:

<static> Success()

β → Validation[α, β]

Constructs a new Etiher[α, β] structure holding a Success value.

Source:

ap()

(@Validation[α, β → γ], f:Applicative[_]) => f[β] → f[γ]

Applies the function inside the Success case of the Validation[α, β] structure to another applicative type.

The Validation[α, β] should contain a function value, otherwise a TypeError is thrown.

Source:

bimap()

(@Validation[α, β]) => (α → γ), (β → δ) → Validation[γ, δ]

Maps both sides of the disjunction.

Source:

failureMap()

(@Validation[α, β]) => (α → γ) → Validation[γ, β]

Maps the failure side of the disjunction.

Source:

fold()

(@Validation[α, β]) => (α → γ), (β → γ) → γ

Applies a function to each case in this data structure.

Source:

get()

(@Validation[α, β]) => Void → β :: partial, throws

Extracts the Success value out of the Validation[α, β] structure, if it exists. Otherwise throws a TypeError.

Source:
See:
Throws:
if the structure has no `Success` value.
Type
TypeError

getOrElse()

(@Validation[α, β]) => β → β

Extracts the Success value out of the Validation[α, β] structure. If the structure doesn't have a Success value, returns the given default.

Source:

isEqual()

(@Validation[α, β]) => Validation[α, β] → Boolean

Tests if an Validation[α, β] structure is equal to another Validation[α, β] structure.

Source:

leftMap()

(@Validation[α, β]) => (α → γ) → Validation[γ, β]

Maps the failure side of the disjunction.

Deprecated:
Source:

map()

(@Validation[α, β]) => (β → γ) → Validation[α, γ]

Transforms the Success value of the Validation[α, β] structure using a regular unary function.

Source:

merge()

(@Validation[α, α]) => Void → α

Returns the value of whichever side of the disjunction that is present.

Source:

orElse()

(@Validation[α, β]) => (α → Validation[γ, β]) → Validation[γ, β]

Transforms a Failure value into a new Validation[α, β] structure. Does nothing if the structure contain a Success value.

Source:

swap()

(@Validation[α, β]) => Void → Validation[β, α]

Swaps the disjunction values.

Source:

toString()

(@Validation[α, β]) => Void → String

Returns a textual representation of the Validation[α, β] structure.

Source: