Validation<E, T> is a type that represents a
state of accumulated failure or success. It is represented by two variants:
Err<E> and Ok<T>.
An Err<E> is a failed Validation and contains a failure of type E.
An Ok<T> is a successful Validation and contains a success of type
T.
The companion Validation:namespace namespace provides utilities
for working with the Validation<E, T> type.
Validation is useful for collecting information about all failures in a
program rather than halting evaluation on the first failure. This behavior
makes Validation a suitable type for validating data from inputs, forms,
and other sources.
Most combinators for Validation begin accumulating failures on the first
failed Validation. Combinators with this behavior require a Semigroup
implementation from the accumulating failures.
Validation with accumulating failures.
Remarks
Validation<E, T>
is a type that represents a state of accumulated failure or success. It is represented by two variants:Err<E>
andOk<T>
.Err<E>
is a failedValidation
and contains a failure of typeE
.Ok<T>
is a successfulValidation
and contains a success of typeT
.The companion
Validation:namespace
namespace provides utilities for working with theValidation<E, T>
type.Validation
is useful for collecting information about all failures in a program rather than halting evaluation on the first failure. This behavior makesValidation
a suitable type for validating data from inputs, forms, and other sources.Most combinators for
Validation
begin accumulating failures on the first failedValidation
. Combinators with this behavior require aSemigroup
implementation from the accumulating failures.Using
Validation
with promisesAsyncValidation<E, T>
is an alias forPromise<Validation<E, T>>
. The companionAsyncValidation:namespace
namespace provides utilities for working with theAsyncValidation<E, T>
type.To accommodate promise-like values, this module also provides the
AsyncValidationLike<E, T>
type as an alias forPromiseLike<Validation<E, T>>
.Importing from this module
The types and namespaces from this module can be imported under the same aliases:
Or, the types and namespaces can be imported and aliased separately: