Validation<MonoidFail, FAIL, SUCCESS> Struct

Like Either but collects the failed values

DECLARATION
public struct Validation<MonoidFail, FAIL, SUCCESS> : IEnumerable<ValidationData<MonoidFail, FAIL, SUCCESS>>,
IComparable<Validation<MonoidFail, FAIL, SUCCESS>>,
IComparable<SUCCESS>,
IEquatable<Validation<MonoidFail, FAIL, SUCCESS>>,
IEquatable<SUCCESS>
NAMESPACE
LanguageExt

Properties

IsFail
DECLARATION
[Pure]
public bool IsFail { get; }
RETURNS
bool
IsSuccess
DECLARATION
[Pure]
public bool IsSuccess { get; }
RETURNS
bool

Methods

BiBind<B>(Func<SUCCESS, Validation<MonoidFail, FAIL, B>>, Func<FAIL, Validation<MonoidFail, FAIL, B>>)
SUMMARY

Bi-bind. Allows mapping of both monad states

PARAMETERS
Succ
Func<SUCCESS, Validation<MonoidFail, FAIL, B>>
Fail
Func<FAIL, Validation<MonoidFail, FAIL, B>>
DECLARATION
[Pure]
public Validation<MonoidFail, FAIL, B> BiBind<B>(Func<SUCCESS, Validation<MonoidFail, FAIL, B>> Succ, Func<FAIL, Validation<MonoidFail, FAIL, B>> Fail)
RETURNS
Validation<MonoidFail, FAIL, B>
BiExists(Func<SUCCESS, bool>, Func<FAIL, bool>)
SUMMARY

Invokes a predicate on the value of the Validation

PARAMETERS
Success
Func<SUCCESS, bool>
Success predicate
Fail
Func<FAIL, bool>
Fail predicate
DECLARATION
[Pure]
public bool BiExists(Func<SUCCESS, bool> Success, Func<FAIL, bool> Fail)
RETURNS
bool
BiFold<S>(S, Func<S, SUCCESS, S>, Func<S, FAIL, S>)
SUMMARY

Validation types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the Fail-identity of the operator), and a list, reduces the list using the binary operator, from Fail to Success:

PARAMETERS
state
S
Initial state
Success
Func<S, SUCCESS, S>
Folder function, applied if Validation is in a Success state
Fail
Func<S, FAIL, S>
Folder function, applied if Validation is in a Fail state
DECLARATION
[Pure]
public S BiFold<S>(S state, Func<S, SUCCESS, S> Success, Func<S, FAIL, S> Fail)
RETURNS
S
The aggregate state
BiForAll(Func<SUCCESS, bool>, Func<FAIL, bool>)
SUMMARY

Invokes a predicate on the value of the Validation if it's in the Success state

PARAMETERS
Success
Func<SUCCESS, bool>
Predicate
Fail
Func<FAIL, bool>
Predicate
DECLARATION
[Pure]
public bool BiForAll(Func<SUCCESS, bool> Success, Func<FAIL, bool> Fail)
RETURNS
bool
True if Validation Predicate returns true
BiIter(Action<SUCCESS>, Action<FAIL>)
SUMMARY

Iterate the Validation action is invoked if in the Success state

PARAMETERS
Success
Action<SUCCESS>
Fail
Action<FAIL>
DECLARATION
public Unit BiIter(Action<SUCCESS> Success, Action<FAIL> Fail)
BiMap<Ret>(Func<SUCCESS, Ret>, Func<FAIL, Ret>)
SUMMARY

Bi-maps the value in the Validation if it's in a Success state

PARAMETERS
Success
Func<SUCCESS, Ret>
Success map function
Fail
Func<FAIL, Ret>
Fail map function
DECLARATION
[Pure]
public Validation<MonoidFail, FAIL, Ret> BiMap<Ret>(Func<SUCCESS, Ret> Success, Func<FAIL, Ret> Fail)
RETURNS
Validation<MonoidFail, FAIL, Ret>
Mapped Validation
Bind<U>(Func<SUCCESS, Validation<MonoidFail, FAIL, U>>)
PARAMETERS
f
Func<SUCCESS, Validation<MonoidFail, FAIL, U>>
DECLARATION
[Pure]
public Validation<MonoidFail, FAIL, U> Bind<U>(Func<SUCCESS, Validation<MonoidFail, FAIL, U>> f)
RETURNS
Validation<MonoidFail, FAIL, U>
CompareTo(Validation<MonoidFail, FAIL, SUCCESS>)
SUMMARY

CompareTo override

PARAMETERS
other
Validation<MonoidFail, FAIL, SUCCESS>
DECLARATION
[Pure]
public int CompareTo(Validation<MonoidFail, FAIL, SUCCESS> other)
RETURNS
int
CompareTo(SUCCESS)
SUMMARY

CompareTo override

PARAMETERS
success
SUCCESS
DECLARATION
[Pure]
public int CompareTo(SUCCESS success)
RETURNS
int
CompareTo(FAIL)
SUMMARY

CompareTo override

PARAMETERS
fail
FAIL
DECLARATION
[Pure]
public int CompareTo(FAIL fail)
RETURNS
int
Count()
SUMMARY

Counts the Validation

DECLARATION
[Pure]
public int Count()
RETURNS
int
1 if the Validation is in a Success state, 0 otherwise.
Disjunction<SUCCESSB>(Validation<MonoidFail, FAIL, SUCCESSB>)
PARAMETERS
other
Validation<MonoidFail, FAIL, SUCCESSB>
DECLARATION
[Pure]
public Validation<MonoidFail, FAIL, SUCCESS> Disjunction<SUCCESSB>(Validation<MonoidFail, FAIL, SUCCESSB> other)
RETURNS
Validation<MonoidFail, FAIL, SUCCESS>
Equals(object)
SUMMARY

Equality check

PARAMETERS
obj
object
Object to test for equality
DECLARATION
[Pure]
public override bool Equals(object obj)
RETURNS
bool
True if equal
Equals(SUCCESS)
SUMMARY

Equality override

PARAMETERS
success
SUCCESS
DECLARATION
[Pure]
public bool Equals(SUCCESS success)
RETURNS
bool
Equals(FAIL)
SUMMARY

Equality override

PARAMETERS
fail
FAIL
DECLARATION
[Pure]
public bool Equals(FAIL fail)
RETURNS
bool
Equals(Validation<MonoidFail, FAIL, SUCCESS>)
SUMMARY

Equality override

PARAMETERS
other
Validation<MonoidFail, FAIL, SUCCESS>
DECLARATION
[Pure]
public bool Equals(Validation<MonoidFail, FAIL, SUCCESS> other)
RETURNS
bool
Exists(Func<SUCCESS, bool>)
SUMMARY

Invokes a predicate on the value of the Validation if it's in the Success state

PARAMETERS
pred
Func<SUCCESS, bool>
Predicate
DECLARATION
[Pure]
public bool Exists(Func<SUCCESS, bool> pred)
RETURNS
bool
True if the Validation is in a Success state and the predicate returns True. False otherwise.
Fail(FAIL)
SUMMARY

Fail constructor

PARAMETERS
fail
FAIL
DECLARATION
[Pure]
public static Validation<MonoidFail, FAIL, SUCCESS> Fail(FAIL fail)
RETURNS
Validation<MonoidFail, FAIL, SUCCESS>
FailAsEnumerable()
SUMMARY

Project the Validation fail into a Seq

DECLARATION
[Pure]
public Seq<FAIL> FailAsEnumerable()
RETURNS
Seq<FAIL>
FailToArray()
SUMMARY

Project the Validation into an immutable array R

DECLARATION
[Pure]
public Arr<FAIL> FailToArray()
RETURNS
Arr<FAIL>
FailToList()
SUMMARY

Project the Validation into a Lst

DECLARATION
[Pure]
public Lst<FAIL> FailToList()
RETURNS
Lst<FAIL>
FailToSeq()
SUMMARY

Convert Validation to sequence of 0 or 1 success values

DECLARATION
[Pure]
public Seq<FAIL> FailToSeq()
RETURNS
Seq<FAIL>
Fold<S>(S, Func<S, SUCCESS, S>)
SUMMARY

Validation types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the Fail-identity of the operator), and a list, reduces the list using the binary operator, from Fail to Success:

PARAMETERS
state
S
Initial state
Success
Func<S, SUCCESS, S>
Folder function, applied if structure is in a Success state
DECLARATION
[Pure]
public S Fold<S>(S state, Func<S, SUCCESS, S> Success)
RETURNS
S
The aggregate state
ForAll(Func<SUCCESS, bool>)
SUMMARY

Invokes a predicate on the value of the Validation if it's in the Success state

PARAMETERS
Success
Func<SUCCESS, bool>
Predicate
DECLARATION
[Pure]
public bool ForAll(Func<SUCCESS, bool> Success)
RETURNS
bool
True if the Validation is in a Fail state. True if the Validation is in a Success state and the predicate returns True. False otherwise.
GetEnumerator()
DECLARATION
public IEnumerator<ValidationData<MonoidFail, FAIL, SUCCESS>> GetEnumerator()
RETURNS
IEnumerator<ValidationData<MonoidFail, FAIL, SUCCESS>>
GetHashCode()
SUMMARY

Returns a hash code of the wrapped value of the Validation

DECLARATION
[Pure]
public override int GetHashCode()
RETURNS
int
Hash code
IfFail(Func<SUCCESS>)
SUMMARY

Executes the Fail function if the Validation is in a Fail state. Returns the Success value if the Validation is in a Success state.

PARAMETERS
Fail
Func<SUCCESS>
Function to generate a Success value if in the Fail state
DECLARATION
[Pure]
public SUCCESS IfFail(Func<SUCCESS> Fail)
RETURNS
SUCCESS
Returns an unwrapped Success value
IfFail(Func<FAIL, SUCCESS>)
SUMMARY

Executes the FailMap function if the Validation is in a Fail state. Returns the Success value if the Validation is in a Success state.

PARAMETERS
FailMap
Func<FAIL, SUCCESS>
Function to generate a Success value if in the Fail state
DECLARATION
[Pure]
public SUCCESS IfFail(Func<FAIL, SUCCESS> FailMap)
RETURNS
SUCCESS
Returns an unwrapped Success value
IfFail(SUCCESS)
SUMMARY

Returns the SuccessValue if the Validation is in a Fail state. Returns the Success value if the Validation is in a Success state.

PARAMETERS
SuccessValue
SUCCESS
Value to return if in the Fail state
DECLARATION
[Pure]
public SUCCESS IfFail(SUCCESS SuccessValue)
RETURNS
SUCCESS
Returns an unwrapped Success value
IfFail(Action<FAIL>)
SUMMARY

Executes the Fail action if the Validation is in a Fail state.

PARAMETERS
Fail
Action<FAIL>
Function to generate a Success value if in the Fail state
DECLARATION
public Unit IfFail(Action<FAIL> Fail)
IfSuccess(Action<SUCCESS>)
SUMMARY

Invokes the Success action if the Validation is in a Success state, otherwise does nothing

PARAMETERS
Success
Action<SUCCESS>
Action to invoke
DECLARATION
public Unit IfSuccess(Action<SUCCESS> Success)
IfSuccess(FAIL)
SUMMARY

Returns the FailValue if the Validation is in a Success state. Returns the Fail value if the Validation is in a Fail state.

PARAMETERS
FailValue
FAIL
Value to return if in the Fail state
DECLARATION
[Pure]
public FAIL IfSuccess(FAIL FailValue)
RETURNS
FAIL
Returns an unwrapped Fail value
IfSuccess(Func<FAIL>)
SUMMARY

Returns the result of Success() if the Validation is in a Success state. Returns the Fail value if the Validation is in a Fail state.

PARAMETERS
Success
Func<FAIL>
Function to generate a Fail value if in the Success state
DECLARATION
[Pure]
public FAIL IfSuccess(Func<FAIL> Success)
RETURNS
FAIL
Returns an unwrapped Fail value
IfSuccess(Func<SUCCESS, FAIL>)
SUMMARY

Returns the result of SuccessMap if the Validation is in a Success state. Returns the Fail value if the Validation is in a Fail state.

PARAMETERS
SuccessMap
Func<SUCCESS, FAIL>
Function to generate a Fail value if in the Success state
DECLARATION
[Pure]
public FAIL IfSuccess(Func<SUCCESS, FAIL> SuccessMap)
RETURNS
FAIL
Returns an unwrapped Fail value
Iter(Action<SUCCESS>)
SUMMARY

Iterate the Validation action is invoked if in the Success state

PARAMETERS
Success
Action<SUCCESS>
DECLARATION
public Unit Iter(Action<SUCCESS> Success)
Map<Ret>(Func<SUCCESS, Ret>)
SUMMARY

Maps the value in the Validation if it's in a Success state

PARAMETERS
mapper
Func<SUCCESS, Ret>
Map function
DECLARATION
[Pure]
public Validation<MonoidFail, FAIL, Ret> Map<Ret>(Func<SUCCESS, Ret> mapper)
RETURNS
Validation<MonoidFail, FAIL, Ret>
Mapped Validation
Match(Action<SUCCESS>, Action<FAIL>)
SUMMARY

Invokes the Succ or Fail action depending on the state of the Validation

PARAMETERS
Succ
Action<SUCCESS>
Action to invoke if in a Success state
Fail
Action<FAIL>
Action to invoke if in a Fail state
DECLARATION
public Unit Match(Action<SUCCESS> Succ, Action<FAIL> Fail)
Match<Ret>(Func<SUCCESS, Ret>, Func<FAIL, Ret>)
SUMMARY

Invokes the Succ or Fail function depending on the state of the Validation

PARAMETERS
Succ
Func<SUCCESS, Ret>
Function to invoke if in a Success state
Fail
Func<FAIL, Ret>
Function to invoke if in a Fail state
DECLARATION
[Pure]
public Ret Match<Ret>(Func<SUCCESS, Ret> Succ, Func<FAIL, Ret> Fail)
RETURNS
Ret
The return value of the invoked function
MatchAsync<R2>(Func<SUCCESS, Task<R2>>, Func<FAIL, R2>)
SUMMARY

Match the two states of the Validation and return a promise for a non-null R2.

PARAMETERS
Succ
Func<SUCCESS, Task<R2>>
Fail
Func<FAIL, R2>
DECLARATION
public Task<R2> MatchAsync<R2>(Func<SUCCESS, Task<R2>> Succ, Func<FAIL, R2> Fail)
RETURNS
Task<R2>
A promise to return a non-null R2
MatchAsync<R2>(Func<SUCCESS, Task<R2>>, Func<FAIL, Task<R2>>)
SUMMARY

Match the two states of the Validation and return a promise for a non-null R2.

PARAMETERS
Succ
Func<SUCCESS, Task<R2>>
Fail
Func<FAIL, Task<R2>>
DECLARATION
public Task<R2> MatchAsync<R2>(Func<SUCCESS, Task<R2>> Succ, Func<FAIL, Task<R2>> Fail)
RETURNS
Task<R2>
A promise to return a non-null R2
MatchObservable<R2>(Func<SUCCESS, IObservable<R2>>, Func<FAIL, R2>)
SUMMARY

Match the two states of the Validation and return an observable stream of non-null R2s.

PARAMETERS
Succ
Func<SUCCESS, IObservable<R2>>
Fail
Func<FAIL, R2>
DECLARATION
[Pure]
public IObservable<R2> MatchObservable<R2>(Func<SUCCESS, IObservable<R2>> Succ, Func<FAIL, R2> Fail)
RETURNS
IObservable<R2>
MatchObservable<R2>(Func<SUCCESS, IObservable<R2>>, Func<FAIL, IObservable<R2>>)
SUMMARY

Match the two states of the Validation and return an observable stream of non-null R2s.

PARAMETERS
Succ
Func<SUCCESS, IObservable<R2>>
Fail
Func<FAIL, IObservable<R2>>
DECLARATION
[Pure]
public IObservable<R2> MatchObservable<R2>(Func<SUCCESS, IObservable<R2>> Succ, Func<FAIL, IObservable<R2>> Fail)
RETURNS
IObservable<R2>
MatchUnsafe<Ret>(Func<SUCCESS, Ret>, Func<FAIL, Ret>)
SUMMARY

Invokes the Succ or Fail function depending on the state of the Validation

PARAMETERS
Succ
Func<SUCCESS, Ret>
Function to invoke if in a Success state
Fail
Func<FAIL, Ret>
Function to invoke if in a Fail state
DECLARATION
[Pure]
public Ret MatchUnsafe<Ret>(Func<SUCCESS, Ret> Succ, Func<FAIL, Ret> Fail)
RETURNS
Ret
The return value of the invoked function
Select<U>(Func<SUCCESS, U>)
SUMMARY

Maps the value in the Validation if it's in a Success state

PARAMETERS
map
Func<SUCCESS, U>
Map function
DECLARATION
[Pure]
public Validation<MonoidFail, FAIL, U> Select<U>(Func<SUCCESS, U> map)
RETURNS
Validation<MonoidFail, FAIL, U>
Mapped Validation
SelectMany<U, V>(Func<SUCCESS, Validation<MonoidFail, FAIL, U>>, Func<SUCCESS, U, V>)
PARAMETERS
bind
Func<SUCCESS, Validation<MonoidFail, FAIL, U>>
project
Func<SUCCESS, U, V>
DECLARATION
[Pure]
public Validation<MonoidFail, FAIL, V> SelectMany<U, V>(Func<SUCCESS, Validation<MonoidFail, FAIL, U>> bind, Func<SUCCESS, U, V> project)
RETURNS
Validation<MonoidFail, FAIL, V>
Success(SUCCESS)
SUMMARY

Success constructor

PARAMETERS
success
SUCCESS
DECLARATION
[Pure]
public static Validation<MonoidFail, FAIL, SUCCESS> Success(SUCCESS success)
RETURNS
Validation<MonoidFail, FAIL, SUCCESS>
SuccessAsEnumerable()
SUMMARY

Project the Validation success into a Seq

DECLARATION
[Pure]
public Seq<SUCCESS> SuccessAsEnumerable()
RETURNS
Seq<SUCCESS>
SuccessToArray()
SUMMARY

Project the Validation into an immutable array

DECLARATION
[Pure]
public Arr<SUCCESS> SuccessToArray()
RETURNS
Arr<SUCCESS>
SuccessToList()
SUMMARY

Project the Validation into a Lst

DECLARATION
[Pure]
public Lst<SUCCESS> SuccessToList()
RETURNS
Lst<SUCCESS>
SuccessToSeq()
SUMMARY

Convert either to sequence of 0 or 1 success values

DECLARATION
[Pure]
public Seq<SUCCESS> SuccessToSeq()
RETURNS
Seq<SUCCESS>
ToEither()
SUMMARY

Convert the Validation to an EitherUnsafe

DECLARATION
[Pure]
public Either<FAIL, SUCCESS> ToEither()
RETURNS
Either<FAIL, SUCCESS>
ToEitherUnsafe()
SUMMARY

Convert the Validation to an EitherUnsafe

DECLARATION
[Pure]
public EitherUnsafe<FAIL, SUCCESS> ToEitherUnsafe()
RETURNS
EitherUnsafe<FAIL, SUCCESS>
ToOption()
SUMMARY

Convert the Validation to an Option

DECLARATION
[Pure]
public Option<SUCCESS> ToOption()
RETURNS
Option<SUCCESS>
ToString()
SUMMARY

Return a string representation of the Validation

DECLARATION
[Pure]
public override string ToString()
RETURNS
string
String representation of the Validation
ToTryOption()
SUMMARY

Convert the Validation to an TryOption

DECLARATION
[Pure]
public TryOption<SUCCESS> ToTryOption()
RETURNS
TryOption<SUCCESS>

Enums

StateType

Fail
Success
DECLARATION
public enum StateType : byte