Skip to content

Latest commit

 

History

History
203 lines (128 loc) · 2.5 KB

Validation.md

File metadata and controls

203 lines (128 loc) · 2.5 KB

MODULE Validation

Validation

data

type Validation<L, A> = Failure<L, A> | Success<L, A>

The Validation functor, used for applicative validation

The Applicative instance collects multiple failures in an arbitrary Semigroup.

Methods

bimap

<V, B>(f: (l: L) => V, g: (a: A) => B): Validation<V, B>

fold

<B>(failure: (l: L) => B, success: (a: A) => B): B

getOrElse

(a: A): A

Returns the value from this Success or the given argument if this is a Failure

getOrElseL

(f: (l: L) => A): A

Returns the value from this Success or the result of given argument if this is a Failure

inspect

(): string

isFailure

(): this is Failure<L, A>

Returns true if the validation is an instance of Failure, false otherwise

isSuccess

(): this is Success<L, A>

Returns true if the validation is an instance of Success, false otherwise

map

<B>(f: (a: A) => B): Validation<L, B>

mapFailure

<M>(f: (l: L) => M): Validation<M, A>

reduce

<B>(b: B, f: (b: B, a: A) => B): B

swap

(): Validation<A, L>

toString

(): string

validation

instance

Functor2<URI> & Foldable2<URI> & Traversable2<URI>

failure

function

<L, A>(l: L): Validation<L, A>

fromEither

function

<L, A>(e: Either<L, A>): Validation<L, A>

fromPredicate

function

<L, A>(predicate: Predicate<A>, f: (a: A) => L) => (a: A): Validation<L, A>

getAlt

function

<L>(S: Semigroup<L>): Alt2C<URI, L>

getApplicative

function

<L>(S: Semigroup<L>): Applicative2C<URI, L>

getMonad

function

<L>(S: Semigroup<L>): Monad2C<URI, L>

getMonoid

function

<L, A>(SL: Semigroup<L>, SA: Monoid<A>): Monoid<Validation<L, A>>

getSemigroup

function

<L, A>(SL: Semigroup<L>, SA: Semigroup<A>): Semigroup<Validation<L, A>>

getSetoid

function

<L, A>(SL: Setoid<L>, SA: Setoid<A>): Setoid<Validation<L, A>>

isFailure

function

<L, A>(fa: Validation<L, A>): fa is Failure<L, A>

Returns true if the validation is an instance of Failure, false otherwise

isSuccess

function

<L, A>(fa: Validation<L, A>): fa is Success<L, A>

Returns true if the validation is an instance of Success, false otherwise

success

function Alias of

of