Validation<FAIL, SUCCESS> Struct

Like Either but collects the failed values

DECLARATION
public struct Validation<FAIL, SUCCESS> : IEnumerable<ValidationData<FAIL, SUCCESS>>,
IComparable<Validation<FAIL, SUCCESS>>,
IComparable<SUCCESS>,
IEquatable<Validation<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

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
True if the predicate returns True. False otherwise.
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<Seq<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<Seq<FAIL>, Ret>
Fail map function
DECLARATION
[Pure]
public Validation<FAIL, Ret> BiMap<Ret>(Func<SUCCESS, Ret> Success, Func<Seq<FAIL>, Ret> Fail)
RETURNS
Validation<FAIL, Ret>
Mapped Validation
Bind<U>(Func<SUCCESS, Validation<FAIL, U>>)
PARAMETERS
f
Func<SUCCESS, Validation<FAIL, U>>
DECLARATION
[Pure]
public Validation<FAIL, U> Bind<U>(Func<SUCCESS, Validation<FAIL, U>> f)
RETURNS
Validation<FAIL, U>
CompareTo(Validation<FAIL, SUCCESS>)
SUMMARY

CompareTo override

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

CompareTo override

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

CompareTo override

PARAMETERS
fail
Seq<FAIL>
DECLARATION
[Pure]
public int CompareTo(Seq<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<FAIL, SUCCESSB>)
PARAMETERS
other
Validation<FAIL, SUCCESSB>
DECLARATION
[Pure]
public Validation<FAIL, SUCCESS> Disjunction<SUCCESSB>(Validation<FAIL, SUCCESSB> other)
RETURNS
Validation<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(Seq<FAIL>)
SUMMARY

Equality override

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

Equality override

PARAMETERS
other
Validation<FAIL, SUCCESS>
DECLARATION
[Pure]
public bool Equals(Validation<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(Seq<FAIL>)
SUMMARY

Fail constructor

PARAMETERS
fail
Seq<FAIL>
DECLARATION
[Pure]
public static Validation<FAIL, SUCCESS> Fail(Seq<FAIL> fail)
RETURNS
Validation<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<FAIL, SUCCESS>> GetEnumerator()
RETURNS
IEnumerator<ValidationData<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<Seq<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<Seq<FAIL>, SUCCESS>
Function to generate a Success value if in the Fail state
DECLARATION
[Pure]
public SUCCESS IfFail(Func<Seq<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<Seq<FAIL>>)
SUMMARY

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

PARAMETERS
Fail
Action<Seq<FAIL>>
Function to generate a Success value if in the Fail state
DECLARATION
public Unit IfFail(Action<Seq<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(Seq<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
Seq<FAIL>
Value to return if in the Fail state
DECLARATION
[Pure]
public Seq<FAIL> IfSuccess(Seq<FAIL> FailValue)
RETURNS
Seq<FAIL>
Returns an unwrapped Fail value
IfSuccess(Func<Seq<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<Seq<FAIL>>
Function to generate a Fail value if in the Success state
DECLARATION
[Pure]
public Seq<FAIL> IfSuccess(Func<Seq<FAIL>> Success)
RETURNS
Seq<FAIL>
Returns an unwrapped Fail value
IfSuccess(Func<SUCCESS, Seq<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, Seq<FAIL>>
Function to generate a Fail value if in the Success state
DECLARATION
[Pure]
public Seq<FAIL> IfSuccess(Func<SUCCESS, Seq<FAIL>> SuccessMap)
RETURNS
Seq<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<FAIL, Ret> Map<Ret>(Func<SUCCESS, Ret> mapper)
RETURNS
Validation<FAIL, Ret>
Mapped Validation
Match(Action<SUCCESS>, Action<Seq<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<Seq<FAIL>>
Action to invoke if in a Fail state
DECLARATION
public Unit Match(Action<SUCCESS> Succ, Action<Seq<FAIL>> Fail)
Match<Ret>(Func<SUCCESS, Ret>, Func<Seq<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<Seq<FAIL>, Ret>
Function to invoke if in a Fail state
DECLARATION
[Pure]
public Ret Match<Ret>(Func<SUCCESS, Ret> Succ, Func<Seq<FAIL>, Ret> Fail)
RETURNS
Ret
The return value of the invoked function
MatchAsync<R2>(Func<SUCCESS, Task<R2>>, Func<Seq<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<Seq<FAIL>, R2>
DECLARATION
public Task<R2> MatchAsync<R2>(Func<SUCCESS, Task<R2>> Succ, Func<Seq<FAIL>, R2> Fail)
RETURNS
Task<R2>
A promise to return a non-null R2
MatchAsync<R2>(Func<SUCCESS, Task<R2>>, Func<Seq<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<Seq<FAIL>, Task<R2>>
DECLARATION
public Task<R2> MatchAsync<R2>(Func<SUCCESS, Task<R2>> Succ, Func<Seq<FAIL>, Task<R2>> Fail)
RETURNS
Task<R2>
A promise to return a non-null R2
MatchObservable<R2>(Func<SUCCESS, IObservable<R2>>, Func<Seq<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<Seq<FAIL>, R2>
DECLARATION
[Pure]
public IObservable<R2> MatchObservable<R2>(Func<SUCCESS, IObservable<R2>> Succ, Func<Seq<FAIL>, R2> Fail)
RETURNS
IObservable<R2>
MatchObservable<R2>(Func<SUCCESS, IObservable<R2>>, Func<Seq<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<Seq<FAIL>, IObservable<R2>>
DECLARATION
[Pure]
public IObservable<R2> MatchObservable<R2>(Func<SUCCESS, IObservable<R2>> Succ, Func<Seq<FAIL>, IObservable<R2>> Fail)
RETURNS
IObservable<R2>
MatchUnsafe<Ret>(Func<SUCCESS, Ret>, Func<Seq<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<Seq<FAIL>, Ret>
Function to invoke if in a Fail state
DECLARATION
[Pure]
public Ret MatchUnsafe<Ret>(Func<SUCCESS, Ret> Succ, Func<Seq<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<FAIL, U> Select<U>(Func<SUCCESS, U> map)
RETURNS
Validation<FAIL, U>
Mapped Validation
SelectMany<U, V>(Func<SUCCESS, Validation<FAIL, U>>, Func<SUCCESS, U, V>)
PARAMETERS
bind
Func<SUCCESS, Validation<FAIL, U>>
project
Func<SUCCESS, U, V>
DECLARATION
[Pure]
public Validation<FAIL, V> SelectMany<U, V>(Func<SUCCESS, Validation<FAIL, U>> bind, Func<SUCCESS, U, V> project)
RETURNS
Validation<FAIL, V>
Success(SUCCESS)
SUMMARY

Success constructor

PARAMETERS
success
SUCCESS
DECLARATION
[Pure]
public static Validation<FAIL, SUCCESS> Success(SUCCESS success)
RETURNS
Validation<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 Either

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

Convert the Validation to an EitherUnsafe

DECLARATION
[Pure]
public EitherUnsafe<Seq<FAIL>, SUCCESS> ToEitherUnsafe()
RETURNS
EitherUnsafe<Seq<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

Success
Fail
DECLARATION
public enum StateType : byte