Package fj.data
Class Validation<E,T>
java.lang.Object
fj.data.Validation<E,T>
- All Implemented Interfaces:
Iterable<T>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A failing projection of a validation. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final F
<String, Validation<NumberFormatException, Byte>> A function that parses a string into a byte.static final F
<String, Validation<NumberFormatException, Double>> A function that parses a string into a double.static final F
<String, Validation<NumberFormatException, Float>> A function that parses a string into a float.static final F
<String, Validation<NumberFormatException, Integer>> A function that parses a string into an integer.static final F
<String, Validation<NumberFormatException, Long>> A function that parses a string into a long.static final F
<String, Validation<NumberFormatException, Short>> A function that parses a string into a short. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <A> Validation
<E, A> accumapply
(Semigroup<E> s, Validation<E, F<T, A>> v) Function application on the successful side of this validation, or accumulating the errors on the failing side using the given semigroup should one or more be encountered.final Validation
<List<E>, T> final <B,
C, D, $E, $F, G, H, I>
Validation<List<E>, I> accumulate
(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, Validation<E, $F> v6, Validation<E, G> v7, Validation<E, H> v8, F8<T, B, C, D, $E, $F, G, H, I> f) final <B,
C, D, $E, $F, G, H>
Validation<List<E>, H> accumulate
(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, Validation<E, $F> v6, Validation<E, G> v7, F7<T, B, C, D, $E, $F, G, H> f) final <B,
C, D, $E, $F, G>
Validation<List<E>, G> accumulate
(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, Validation<E, $F> v6, F6<T, B, C, D, $E, $F, G> f) final <B,
C, D, $E, $F>
Validation<List<E>, $F> accumulate
(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, F5<T, B, C, D, $E, $F> f) final <B,
C, D, $E>
Validation<List<E>, $E> accumulate
(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, F4<T, B, C, D, $E> f) final <B,
C, D> Validation <List<E>, D> accumulate
(Validation<E, B> v2, Validation<E, C> v3, F3<T, B, C, D> f) final <B,
C> Validation <List<E>, C> accumulate
(Validation<E, B> v2, F2<T, B, C> f) final <B> Validation
<List<E>, B> accumulate
(F<T, B> f) accumulate
(Semigroup<E> s, Validation<E, A> va) Accumulates errors anonymously.accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb) Accumulates errors anonymously.accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc) Accumulates errors anonymously.accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd) Accumulates errors anonymously.accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve) Accumulates errors anonymously.accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf) Accumulates errors anonymously.accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf, Validation<E, G> vg) Accumulates errors anonymously.final <A,
B, C, D, E$, F$, G, H>
Validation<E, H> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf, Validation<E, G> vg, F<T, F<A, F<B, F<C, F<D, F<E$, F<F$, F<G, H>>>>>>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C, D, E$, F$, G, H>
Validation<E, H> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf, Validation<E, G> vg, F8<T, A, B, C, D, E$, F$, G, H> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C, D, E$, F$, G>
Validation<E, G> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf, F<T, F<A, F<B, F<C, F<D, F<E$, F<F$, G>>>>>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C, D, E$, F$, G>
Validation<E, G> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf, F7<T, A, B, C, D, E$, F$, G> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C, D, E$, F$>
Validation<E, F$> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, F<T, F<A, F<B, F<C, F<D, F<E$, F$>>>>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C, D, E$, F$>
Validation<E, F$> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, F6<T, A, B, C, D, E$, F$> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C, D, E$>
Validation<E, E$> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, F<T, F<A, F<B, F<C, F<D, E$>>>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C, D, E$>
Validation<E, E$> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, F5<T, A, B, C, D, E$> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C, D>
Validation<E, D> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, F<T, F<A, F<B, F<C, D>>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C, D>
Validation<E, D> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, F4<T, A, B, C, D> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C> Validation <E, C> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, F<T, F<A, F<B, C>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B, C> Validation <E, C> accumulate
(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, F3<T, A, B, C> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B> Validation <E, B> accumulate
(Semigroup<E> s, Validation<E, A> va, F<T, F<A, B>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A,
B> Validation <E, B> accumulate
(Semigroup<E> s, Validation<E, A> va, F2<T, A, B> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.final <A> Validation
<E, A> apply
(Validation<E, F<T, A>> v) Function application on the success value.final <A> Validation
<E, A> bind
(F<T, Validation<E, A>> f) Binds the given function across this validation's success value if it has one.static <E,
T> Validation <E, T> condition
(boolean c, E e, T t) Returns a validation based on a boolean condition.static <E,
T> F <Validation<E, T>, Either<E, T>> either()
Returns a function that constructs an either with a validation.final boolean
final boolean
Returnsfalse
if this is a failure or returns the result of the application of the given function to the success value.final Validation.FailProjection
<E, T> f()
Returns a failing projection of this validation.final E
fail()
Returns the failing value, or throws an error if there is no failing value.static <E,
T> Validation <E, T> fail
(E e) Returns a failing validation containing the given value.static <E,
T> Validation <NonEmptyList<E>, T> failNEL
(E e) Returns a failing validation containing a non-empty list that contains the given value.static <A,
E> List <E> fails
(List<Validation<E, ?>> list) final <A> Option
<Validation<A, T>> ReturnsNone
if this is a failure or if the given predicatep
does not hold for the success value, otherwise, returns a success inSome
.final boolean
Returnstrue
if this is a failure or returns the result of the application of the given function to the success value.final Unit
Executes a side-effect on the success value if there is one.final void
foreachDoEffect
(Effect1<T> f) Executes a side-effect on the success value if there is one.final int
hashCode()
final boolean
isFail()
Returnstrue
if this is a failure,false
otherwise.final boolean
Returnstrue
if this is a success,false
otherwise.iterator()
Returns an iterator for this validation.final <A> Validation
<E, A> Maps the given function across the success side of this validation.final Validation
<NonEmptyList<E>, T> nel()
Puts this validation's failing value in a non-empty list if there is one.final T
The success value or the application of the given function to the failing value.final T
Returns the success value or the given value.final T
Returns the success value or the given value.static Validation
<NumberFormatException, Byte> Parses the given string into a byte.static Validation
<NumberFormatException, Double> Parses the given string into a double.static Validation
<NumberFormatException, Float> parseFloat
(String s) Parses the given string into a float.static Validation
<NumberFormatException, Integer> Parses the given string into a integer.static Validation
<NumberFormatException, Long> Parses the given string into a long.static Validation
<NumberFormatException, Short> parseShort
(String s) Parses the given string into a short.partition
(List<Validation<A, B>> list) Partitions the list into the list of fails and the list of successesfinal <A> Validation
<E, A> sequence
(Validation<E, A> v) Anonymous bind through this validation.static <E,
A> Validation <E, List<A>> sequence
(Semigroup<E> s, List<Validation<E, A>> list) If list contains a failure, returns a failure of the reduction of all the failures using the semigroup, otherwise returns the successful list.static final <E,
R, C> Either <Validation<E, C>, R> sequenceEitherLeft
(Validation<E, Either<C, R>> validation) Sequence the given validation and collect the output on the left side of an either.static final <E,
L, C> Either <L, Validation<E, C>> sequenceEitherRight
(Validation<E, Either<L, C>> validation) Sequence the given validation and collect the output on the right side of an either.static final <E,
C, B> F <C, Validation<E, B>> sequenceF
(Validation<E, F<C, B>> validation) Sequence the given validation and collect the output as a function.static final <E,
C> IO <Validation<E, C>> sequenceIO
(Validation<E, IO<C>> validation) Sequence the given validation and collect the output as an IO.static final <E,
C> List <Validation<E, C>> sequenceList
(Validation<E, List<C>> validation) Sequence the given validation and collect the output as a list.static <A,
E> Validation <List<E>, List<A>> sequenceNonCumulative
(List<Validation<E, A>> list) If the list contains a failure, returns a Validation of the list of fails in the list, otherwise returns a successful Validation with the list of successful values.static final <E,
C> Option <Validation<E, C>> sequenceOption
(Validation<E, Option<C>> validation) Sequence the given validation and collect the output as an option.static final <E,
C> P1 <Validation<E, C>> sequenceP1
(Validation<E, P1<C>> validation) Sequence the given validation and collect the output as a P1.static final <E,
C> Seq <Validation<E, C>> sequenceSeq
(Validation<E, Seq<C>> validation) Sequence the given validation and collect the output as a seq.static final <E,
C> Set <Validation<E, C>> sequenceSet
(Ord<E> ordE, Ord<C> ordC, Validation<E, Set<C>> validation) Sequence the given validation and collect the output as a set.static final <E,
C> Stream <Validation<E, C>> sequenceStream
(Validation<E, Stream<C>> validation) Sequence the given validation and collect the output as a stream.static final <E,
C> Trampoline <Validation<E, C>> sequenceTrampoline
(Validation<E, Trampoline<C>> validation) Sequence the given validation and collect the output as a trampoline.static final <E,
E1, C> Validation <E1, Validation<E, C>> sequenceValidation
(Validation<E, Validation<E1, C>> validation) Sequence the given validation and collect the output as a validation.final T
success()
Returns the success value, or throws an error if there is no success value.static <E,
T> Validation <E, T> success
(T t) Returns a succeeding validation containing the given value.final T
Returns the success value or fails with the given error message.final T
Returns the success value or fails with the given error message.static <A,
E> List <A> successes
(List<Validation<E, A>> list) toArray()
Returns a single element array if this is a success value, otherwise an empty list.toEither()
Returns an either projection of this validation.toList()
Returns a single element list if this is a success value, otherwise an empty list.toOption()
Returns the success value inSome
if there is one, otherwiseNone
.toStream()
Returns a single element stream if this is a success value, otherwise an empty list.final String
toString()
final <R,
C> Either <Validation<E, C>, R> traverseEitherLeft
(F<T, Either<C, R>> f) Traverse this validation with the given function and collect the output on the left side of an either.final <L,
C> Either <L, Validation<E, C>> traverseEitherRight
(F<T, Either<L, C>> f) Traverse this validation with the given function and collect the output on the right side of an either.final <C,
B> F <C, Validation<E, B>> Traverse this validation with the given function and collect the output as a function.final <C> IO
<Validation<E, C>> traverseIO
(F<T, IO<C>> f) Traverse this validation with the given function and collect the output as an IO.final <C> List
<Validation<E, C>> traverseList
(F<T, List<C>> f) Traverse this validation with the given function and collect the output as a list.final <C> Option
<Validation<E, C>> traverseOption
(F<T, Option<C>> f) Traverse this validation with the given function and collect the output as an option.final <C> P1
<Validation<E, C>> traverseP1
(F<T, P1<C>> f) Traverse this validation with the given function and collect the output as a P1.final <C> Seq
<Validation<E, C>> traverseSeq
(F<T, Seq<C>> f) Traverse this validation with the given function and collect the output as a seq.final <C> Set
<Validation<E, C>> Traverse this validation with the given function and collect the output as a set; use the given success and failure value ords to order the set.final <C> Stream
<Validation<E, C>> traverseStream
(F<T, Stream<C>> f) Traverse this validation with the given function and collect the output as a stream.final <C> Trampoline
<Validation<E, C>> traverseTrampoline
(F<T, Trampoline<C>> f) Traverse this validation with the given function and collect the output as a trampoline.final <E1,
C> Validation <E1, Validation<E, C>> traverseValidation
(F<T, Validation<E1, C>> f) Traverse this validation with the given function and collect the output as a validation.static <E,
T> F <Either<E, T>, Validation<E, T>> Returns a function that constructs a validation with an either.static <E,
T> Validation <E, T> validation
(Either<E, T> e) Construct a validation using the given either value.final <X> X
validation
(F<E, X> fail, F<T, X> success) The catamorphism for validation.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
e
-
parseByte
A function that parses a string into a byte. -
parseDouble
A function that parses a string into a double. -
parseFloat
A function that parses a string into a float. -
parseInt
A function that parses a string into an integer. -
parseLong
A function that parses a string into a long. -
parseShort
A function that parses a string into a short.
-
-
Constructor Details
-
Validation
-
-
Method Details
-
isFail
public final boolean isFail()Returnstrue
if this is a failure,false
otherwise.- Returns:
true
if this is a failure,false
otherwise.
-
isSuccess
public final boolean isSuccess()Returnstrue
if this is a success,false
otherwise.- Returns:
true
if this is a success,false
otherwise.
-
fail
Returns the failing value, or throws an error if there is no failing value.- Returns:
- the failing value, or throws an error if there is no failing value.
-
success
Returns the success value, or throws an error if there is no success value.- Returns:
- the success value, or throws an error if there is no success value.
-
validation
The catamorphism for validation. Folds over this validation breaking into left or right.- Parameters:
fail
- The function to call if this failed.success
- The function to call if this succeeded.- Returns:
- The reduced value.
-
f
Returns a failing projection of this validation.- Returns:
- a failing projection of this validation.
-
toEither
Returns an either projection of this validation.- Returns:
- An either projection of this validation.
-
successE
Returns the success value or fails with the given error message.- Parameters:
err
- The error message to fail with.- Returns:
- The success value.
-
successE
Returns the success value or fails with the given error message.- Parameters:
err
- The error message to fail with.- Returns:
- The success value.
-
orSuccess
Returns the success value or the given value.- Parameters:
t
- The value to return if this is failure.- Returns:
- The success value or the given value.
-
orSuccess
Returns the success value or the given value.- Parameters:
t
- The value to return if this is failure.- Returns:
- The success value or the given value.
-
on
The success value or the application of the given function to the failing value.- Parameters:
f
- The function to execute on the failing value.- Returns:
- The success value or the application of the given function to the failing value.
-
foreach
Executes a side-effect on the success value if there is one.- Parameters:
f
- The side-effect to execute.- Returns:
- The unit value.
-
foreachDoEffect
Executes a side-effect on the success value if there is one.- Parameters:
f
- The side-effect to execute.
-
map
Maps the given function across the success side of this validation.- Parameters:
f
- The function to map.- Returns:
- A new validation with the function mapped.
-
bind
Binds the given function across this validation's success value if it has one.- Parameters:
f
- The function to bind across this validation.- Returns:
- A new validation value after binding.
-
sequence
Anonymous bind through this validation.- Parameters:
v
- The value to bind with.- Returns:
- A validation after binding.
-
sequence
If list contains a failure, returns a failure of the reduction of all the failures using the semigroup, otherwise returns the successful list. -
filter
ReturnsNone
if this is a failure or if the given predicatep
does not hold for the success value, otherwise, returns a success inSome
.- Parameters:
f
- The predicate function to test on this success value.- Returns:
None
if this is a failure or if the given predicatep
does not hold for the success value, otherwise, returns a success inSome
.
-
apply
Function application on the success value.- Parameters:
v
- The validation of the function to apply on the success value.- Returns:
- The result of function application in validation.
-
forall
Returnstrue
if this is a failure or returns the result of the application of the given function to the success value.- Parameters:
f
- The predicate function to test on this success value.- Returns:
true
if this is a failure or returns the result of the application of the given function to the success value.
-
exists
Returnsfalse
if this is a failure or returns the result of the application of the given function to the success value.- Parameters:
f
- The predicate function to test on this success value.- Returns:
false
if this is a failure or returns the result of the application of the given function to the success value.
-
equals
-
hashCode
public final int hashCode() -
toList
Returns a single element list if this is a success value, otherwise an empty list.- Returns:
- A single element list if this is a success value, otherwise an empty list.
-
toOption
Returns the success value inSome
if there is one, otherwiseNone
.- Returns:
- The success value in
Some
if there is one, otherwiseNone
.
-
toArray
Returns a single element array if this is a success value, otherwise an empty list.- Returns:
- A single element array if this is a success value, otherwise an empty list.
-
toStream
Returns a single element stream if this is a success value, otherwise an empty list.- Returns:
- A single element stream if this is a success value, otherwise an empty list.
-
accumapply
Function application on the successful side of this validation, or accumulating the errors on the failing side using the given semigroup should one or more be encountered.- Parameters:
s
- The semigroup to accumulate errors with ifv
- The validating function to apply.- Returns:
- A failing validation if this or the given validation failed (with errors accumulated if both) or a succeeding validation if both succeeded.
-
accumulate
Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
Accumulates errors anonymously.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.- Returns:
- A
Some
if one or more validations failed (accumulated with the semigroup), otherwise,None
.
-
accumulate
public final <A,B, Validation<E,C> C> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, F<T, F<A, F<B, C>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Validation<E,C> C> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, F3<T, A, B, C> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
Accumulates errors anonymously.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.- Returns:
- A
Some
if one or more validations failed (accumulated with the semigroup), otherwise,None
.
-
accumulate
public final <A,B, Validation<E,C, D> D> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, F<T, F<A, F<B, F<C, D>>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Validation<E,C, D> D> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, F4<T, A, B, C, D> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Option<E> accumulateC> (Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc) Accumulates errors anonymously.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.- Returns:
- A
Some
if one or more validations failed (accumulated with the semigroup), otherwise,None
.
-
accumulate
public final <A,B, Validation<E,C, D, E$> E$> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, F<T, F<A, F<B, F<C, F<D, E$>>>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Validation<E,C, D, E$> E$> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, F5<T, A, B, C, D, E$> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Option<E> accumulateC, D> (Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd) Accumulates errors anonymously.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.- Returns:
- A
Some
if one or more validations failed (accumulated with the semigroup), otherwise,None
.
-
accumulate
public final <A,B, Validation<E,C, D, E$, F$> F$> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, F<T, F<A, F<B, F<C, F<D, F<E$, F$>>>>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.ve
- The sixth validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Validation<E,C, D, E$, F$> F$> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, F6<T, A, B, C, D, E$, F$> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.ve
- The sixth validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Option<E> accumulateC, D, E$> (Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve) Accumulates errors anonymously.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.ve
- The sixth validation to accumulate errors with if it failed.- Returns:
- A
Some
if one or more validations failed (accumulated with the semigroup), otherwise,None
.
-
accumulate
public final <A,B, Validation<E,C, D, E$, F$, G> G> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf, F<T, F<A, F<B, F<C, F<D, F<E$, F<F$, G>>>>>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.ve
- The sixth validation to accumulate errors with if it failed.vf
- The seventh validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Validation<E,C, D, E$, F$, G> G> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf, F7<T, A, B, C, D, E$, F$, G> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.ve
- The sixth validation to accumulate errors with if it failed.vf
- The seventh validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Option<E> accumulateC, D, E$, F$> (Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf) Accumulates errors anonymously.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.ve
- The sixth validation to accumulate errors with if it failed.vf
- The seventh validation to accumulate errors with if it failed.- Returns:
- A
Some
if one or more validations failed (accumulated with the semigroup), otherwise,None
.
-
accumulate
public final <A,B, Validation<E,C, D, E$, F$, G, H> H> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf, Validation<E, G> vg, F<T, F<A, F<B, F<C, F<D, F<E$, F<F$, F<G, H>>>>>>>> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.ve
- The sixth validation to accumulate errors with if it failed.vf
- The seventh validation to accumulate errors with if it failed.vg
- The eighth validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Validation<E,C, D, E$, F$, G, H> H> accumulate(Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf, Validation<E, G> vg, F8<T, A, B, C, D, E$, F$, G, H> f) Accumulates errors on the failing side of this or any given validation if one or more are encountered, or applies the given function if all succeeded and returns that value on the successful side.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.ve
- The sixth validation to accumulate errors with if it failed.vf
- The seventh validation to accumulate errors with if it failed.vg
- The eighth validation to accumulate errors with if it failed.f
- The function to apply if all validations have succeeded.- Returns:
- A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if one or more failed.
-
accumulate
public final <A,B, Option<E> accumulateC, D, E$, F$, G> (Semigroup<E> s, Validation<E, A> va, Validation<E, B> vb, Validation<E, C> vc, Validation<E, D> vd, Validation<E, E$> ve, Validation<E, F$> vf, Validation<E, G> vg) Accumulates errors anonymously.- Parameters:
s
- The semigroup to accumulate errors with if one or more validations fail.va
- The second validation to accumulate errors with if it failed.vb
- The third validation to accumulate errors with if it failed.vc
- The fourth validation to accumulate errors with if it failed.vd
- The fifth validation to accumulate errors with if it failed.ve
- The sixth validation to accumulate errors with if it failed.vf
- The seventh validation to accumulate errors with if it failed.vg
- The eighth validation to accumulate errors with if it failed.- Returns:
- A
Some
if one or more validations failed (accumulated with the semigroup), otherwise,None
.
-
iterator
Returns an iterator for this validation. This method exists to permit the use in afor
-each loop. -
accumulate
-
accumulate
-
accumulate
-
accumulate
public final <B,C, Validation<List<E>,D> D> accumulate(Validation<E, B> v2, Validation<E, C> v3, F3<T, B, C, D> f) -
accumulate
public final <B,C, Validation<List<E>,D, $E> $E> accumulate(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, F4<T, B, C, D, $E> f) -
accumulate
public final <B,C, Validation<List<E>,D, $E, $F> $F> accumulate(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, F5<T, B, C, D, $E, $F> f) -
accumulate
public final <B,C, Validation<List<E>,D, $E, $F, G> G> accumulate(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, Validation<E, $F> v6, F6<T, B, C, D, $E, $F, G> f) -
accumulate
public final <B,C, Validation<List<E>,D, $E, $F, G, H> H> accumulate(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, Validation<E, $F> v6, Validation<E, G> v7, F7<T, B, C, D, $E, $F, G, H> f) -
accumulate
public final <B,C, Validation<List<E>,D, $E, $F, G, H, I> I> accumulate(Validation<E, B> v2, Validation<E, C> v3, Validation<E, D> v4, Validation<E, $E> v5, Validation<E, $F> v6, Validation<E, G> v7, Validation<E, H> v8, F8<T, B, C, D, $E, $F, G, H, I> f) -
sequenceNonCumulative
If the list contains a failure, returns a Validation of the list of fails in the list, otherwise returns a successful Validation with the list of successful values. Does not accumulate the failures into a single failure using a semigroup. -
sequenceEitherLeft
public static final <E,R, Either<Validation<E,C> C>, sequenceEitherLeftR> (Validation<E, Either<C, R>> validation) Sequence the given validation and collect the output on the left side of an either.- Type Parameters:
E
- the type of the failure valueR
- the type of the right valueC
- the type of the left value- Parameters:
validation
- the given validation- Returns:
- the either
-
sequenceEitherRight
public static final <E,L, Either<L,C> Validation<E, sequenceEitherRightC>> (Validation<E, Either<L, C>> validation) Sequence the given validation and collect the output on the right side of an either.- Type Parameters:
E
- the type of the failure valueL
- the type of the left valueC
- the type of the right value- Parameters:
validation
- the given validation- Returns:
- the either
-
sequenceF
Sequence the given validation and collect the output as a function.- Type Parameters:
E
- the type of the failure valueC
- the type of input valueB
- the type of output value- Parameters:
validation
- the given validation- Returns:
- the function
-
sequenceIO
Sequence the given validation and collect the output as an IO.- Type Parameters:
E
- the type of the failure valueC
- the type of the IO value- Parameters:
validation
- the given validation- Returns:
- the IO
-
sequenceList
Sequence the given validation and collect the output as a list.- Type Parameters:
E
- the type of the failure valueC
- the type of the list value- Parameters:
validation
- the given validation- Returns:
- the list
-
sequenceOption
public static final <E,C> Option<Validation<E,C>> sequenceOption(Validation<E, Option<C>> validation) Sequence the given validation and collect the output as an option.- Type Parameters:
E
- the type of the failure valueC
- the type of the option value- Parameters:
validation
- the given validation- Returns:
- the option
-
sequenceP1
Sequence the given validation and collect the output as a P1.- Type Parameters:
E
- the type of the failure valueC
- the type of the P1 value- Parameters:
validation
- the given validation- Returns:
- the P1
-
sequenceSeq
Sequence the given validation and collect the output as a seq.- Type Parameters:
E
- the type of the failure valueC
- the type of the seq value- Parameters:
validation
- the given validation- Returns:
- the seq
-
sequenceSet
public static final <E,C> Set<Validation<E,C>> sequenceSet(Ord<E> ordE, Ord<C> ordC, Validation<E, Set<C>> validation) Sequence the given validation and collect the output as a set.- Type Parameters:
E
- the type of the failure valueC
- the type of the set value- Parameters:
ordE
- the given failure value ordordC
- the given success value ordvalidation
- the given validation- Returns:
- the set
-
sequenceStream
public static final <E,C> Stream<Validation<E,C>> sequenceStream(Validation<E, Stream<C>> validation) Sequence the given validation and collect the output as a stream.- Type Parameters:
E
- the type of the failure valueC
- the type of the stream value- Parameters:
validation
- the given validation- Returns:
- the stream
-
sequenceTrampoline
public static final <E,C> Trampoline<Validation<E,C>> sequenceTrampoline(Validation<E, Trampoline<C>> validation) Sequence the given validation and collect the output as a trampoline.- Type Parameters:
E
- the type of the failure valueC
- the type of the trampoline value- Parameters:
validation
- the given validation- Returns:
- the trampoline
-
sequenceValidation
public static final <E,E1, Validation<E1,C> Validation<E, sequenceValidationC>> (Validation<E, Validation<E1, C>> validation) Sequence the given validation and collect the output as a validation.- Type Parameters:
E
- the type of the failure valueE1
- the type of the failure valueC
- the type of the success value- Parameters:
validation
- the given validation- Returns:
- the validation
-
traverseEitherLeft
Traverse this validation with the given function and collect the output on the left side of an either.- Type Parameters:
R
- the type of the right valueC
- the type of the left value- Parameters:
f
- the given function- Returns:
- the list
-
traverseEitherRight
Traverse this validation with the given function and collect the output on the right side of an either.- Type Parameters:
L
- the type of the left valueC
- the type of the right value- Parameters:
f
- the given function- Returns:
- the list
-
traverseF
Traverse this validation with the given function and collect the output as a function.- Type Parameters:
C
- the type of the input valueB
- the type of the output value- Parameters:
f
- the given function- Returns:
- the function
-
traverseIO
Traverse this validation with the given function and collect the output as an IO.- Type Parameters:
C
- the type of the IO value- Parameters:
f
- the given function- Returns:
- the IO
-
traverseList
Traverse this validation with the given function and collect the output as a list.- Type Parameters:
C
- the type of the list value- Parameters:
f
- the given function- Returns:
- the list
-
traverseOption
Traverse this validation with the given function and collect the output as an option.- Type Parameters:
C
- the type of the option value- Parameters:
f
- the given function- Returns:
- the option
-
traverseP1
Traverse this validation with the given function and collect the output as a P1.- Type Parameters:
C
- the type of the P1 value- Parameters:
f
- the given function- Returns:
- the P1
-
traverseSeq
Traverse this validation with the given function and collect the output as a seq.- Type Parameters:
C
- the type of the seq value- Parameters:
f
- the given function- Returns:
- the seq
-
traverseSet
Traverse this validation with the given function and collect the output as a set; use the given success and failure value ords to order the set.- Type Parameters:
C
- the type of the set value- Parameters:
ordE
- the given failure value ordordC
- the given success value ordf
- the given function- Returns:
- the set
-
traverseStream
Traverse this validation with the given function and collect the output as a stream.- Type Parameters:
C
- the type of the stream value- Parameters:
f
- the given function- Returns:
- the stream
-
traverseTrampoline
Traverse this validation with the given function and collect the output as a trampoline.- Type Parameters:
C
- the type of the trampoline value- Parameters:
f
- the given function- Returns:
- the trampoline
-
traverseValidation
Traverse this validation with the given function and collect the output as a validation.- Type Parameters:
E1
- the type of the failure valueC
- the type of the seq value- Parameters:
f
- the given function- Returns:
- the validation
-
fails
-
successes
-
nel
Puts this validation's failing value in a non-empty list if there is one.- Returns:
- A validation with its failing value in a non-empty list if there is one.
-
validation
Construct a validation using the given either value.- Parameters:
e
- The either value to construct a validation with.- Returns:
- A validation using the given either value.
-
validation
Returns a function that constructs a validation with an either.- Returns:
- A function that constructs a validation with an either.
-
either
Returns a function that constructs an either with a validation.- Returns:
- A function that constructs an either with a validation.
-
success
Returns a succeeding validation containing the given value.- Parameters:
t
- The value to use in the succeeding validation.- Returns:
- A succeeding validation containing the given value.
-
fail
Returns a failing validation containing the given value.- Parameters:
e
- The value to use in the failing validation.- Returns:
- A failing validation containing the given value.
-
failNEL
Returns a failing validation containing a non-empty list that contains the given value.- Parameters:
e
- The value to use in a non-empty list for the failing validation.- Returns:
- A failing validation containing a non-empty list that contains the given value.
-
condition
Returns a validation based on a boolean condition. If the condition istrue
, the validation succeeds, otherwise it fails.- Parameters:
c
- The condition to base the returned validation on.e
- The failing value to use if the condition isfalse
.t
- The succeeding value to use if the condition istrue
.- Returns:
- A validation based on a boolean condition.
-
parseByte
Parses the given string into a byte.- Parameters:
s
- The string to parse.- Returns:
- A successfully parse byte or a failing exception.
-
parseDouble
Parses the given string into a double.- Parameters:
s
- The string to parse.- Returns:
- A successfully parse double or a failing exception.
-
parseFloat
Parses the given string into a float.- Parameters:
s
- The string to parse.- Returns:
- A successfully parse float or a failing exception.
-
parseInt
Parses the given string into a integer.- Parameters:
s
- The string to parse.- Returns:
- A successfully parse integer or a failing exception.
-
parseLong
Parses the given string into a long.- Parameters:
s
- The string to parse.- Returns:
- A successfully parse long or a failing exception.
-
parseShort
Parses the given string into a short.- Parameters:
s
- The string to parse.- Returns:
- A successfully parse short or a failing exception.
-
partition
Partitions the list into the list of fails and the list of successes -
toString
-