fj.data.Validation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionaljava Show documentation
Show all versions of functionaljava Show documentation
Functional Java is an open source library that supports closures for the Java programming language
package fj.data;
import fj.*;
import fj.function.Effect1;
import static fj.Function.curry;
import static fj.P.p;
import static fj.Unit.unit;
import static fj.Bottom.error;
import static fj.data.List.list;
import java.util.Iterator;
/**
* Isomorphic to {@link Either} but has renamed functions and represents failure on the left and success on the right.
* This type also has accumulating functions that accept a {@link Semigroup} for binding computation while keeping error
* values
*
* @version %build.number%
*/
public class Validation implements Iterable {
private final Either e;
protected Validation(final Either e) {
this.e = e;
}
/**
* Returns true
if this is a failure, false
otherwise.
*
* @return true
if this is a failure, false
otherwise.
*/
public boolean isFail() {
return e.isLeft();
}
/**
* Returns true
if this is a success, false
otherwise.
*
* @return true
if this is a success, false
otherwise.
*/
public boolean isSuccess() {
return e.isRight();
}
/**
* Returns the failing value, or throws an error if there is no failing value.
*
* @return the failing value, or throws an error if there is no failing value.
*/
public E fail() {
if (isFail())
return e.left().value();
else
throw error("Validation: fail on success value");
}
/**
* Returns the success value, or throws an error if there is no success value.
*
* @return the success value, or throws an error if there is no success value.
*/
public T success() {
if (isSuccess())
return e.right().value();
else
throw error("Validation: success on fail value");
}
/**
* The catamorphism for validation. Folds over this validation breaking into left or right.
*
* @param fail The function to call if this failed.
* @param success The function to call if this succeeded.
* @return The reduced value.
*/
public X validation(final F fail, final F success) {
return e.either(fail, success);
}
/**
* Returns a failing projection of this validation.
*
* @return a failing projection of this validation.
*/
public FailProjection f() {
return new FailProjection(this);
}
/**
* Returns an either projection of this validation.
*
* @return An either projection of this validation.
*/
public Either toEither() {
return e;
}
/**
* Returns the success value or fails with the given error message.
*
* @param err The error message to fail with.
* @return The success value.
*/
public T successE(final F0 err) {
return e.right().valueE(err);
}
/**
* Returns the success value or fails with the given error message.
*
* @param err The error message to fail with.
* @return The success value.
*/
public T successE(final String err) {
return e.right().valueE(p(err));
}
/**
* Returns the success value or the given value.
*
* @param t The value to return if this is failure.
* @return The success value or the given value.
*/
public T orSuccess(final F0 t) {
return e.right().orValue(t);
}
/**
* Returns the success value or the given value.
*
* @param t The value to return if this is failure.
* @return The success value or the given value.
*/
public T orSuccess(final T t) {
return e.right().orValue(p(t));
}
/**
* The success value or the application of the given function to the failing value.
*
* @param f The function to execute on the failing value.
* @return The success value or the application of the given function to the failing value.
*/
public T on(final F f) {
return e.right().on(f);
}
/**
* Executes a side-effect on the success value if there is one.
*
* @param f The side-effect to execute.
* @return The unit value.
*/
public Unit foreach(final F f) {
return e.right().foreach(f);
}
/**
* Executes a side-effect on the success value if there is one.
*
* @param f The side-effect to execute.
*/
public void foreachDoEffect(final Effect1 f) {
e.right().foreachDoEffect(f);
}
/**
* Maps the given function across the success side of this validation.
*
* @param f The function to map.
* @return A new validation with the function mapped.
*/
@SuppressWarnings({"unchecked"})
public Validation map(final F f) {
return isFail() ?
Validation.fail(fail()) :
Validation.success(f.f(success()));
}
/**
* Binds the given function across this validation's success value if it has one.
*
* @param f The function to bind across this validation.
* @return A new validation value after binding.
*/
@SuppressWarnings({"unchecked"})
public Validation bind(final F> f) {
return isSuccess() ? f.f(success()) : Validation.fail(fail());
}
/**
* Anonymous bind through this validation.
*
* @param v The value to bind with.
* @return A validation after binding.
*/
public Validation sequence(final Validation v) {
return bind(Function.>constant(v));
}
/**
* If list contains a failure, returns a failure of the reduction of
* all the failures using the semigroup, otherwise returns the successful list.
*/
public static Validation> sequence(final Semigroup s, final List> list) {
if (list.exists(v -> v.isFail())) {
return Validation.>fail(list.filter(v -> v.isFail()).map(v -> v.fail()).foldLeft1((e1, e2) -> s.sum(e1, e2)));
} else {
return Validation.success(list.foldLeft((List acc, Validation v) -> acc.cons(v.success()), List.nil()).reverse());
}
}
/**
* Returns None
if this is a failure or if the given predicate p
does not hold for the
* success value, otherwise, returns a success in Some
.
*
* @param f The predicate function to test on this success value.
* @return None
if this is a failure or if the given predicate p
does not hold for the
* success value, otherwise, returns a success in Some
.
*/
public Option> filter(final F f) {
return e.right().filter(f).map(Validation.validation());
}
/**
* Function application on the success value.
*
* @param v The validation of the function to apply on the success value.
* @return The result of function application in validation.
*/
public Validation apply(final Validation> v) {
return v.bind(new F, Validation>() {
public Validation f(final F f) {
return map(f);
}
});
}
/**
* Returns true
if this is a failure or returns the result of the application of the given
* function to the success value.
*
* @param f The predicate function to test on this success value.
* @return true
if this is a failure or returns the result of the application of the given
* function to the success value.
*/
public boolean forall(final F f) {
return e.right().forall(f);
}
/**
* Returns false
if this is a failure or returns the result of the application of the given
* function to the success value.
*
* @param f The predicate function to test on this success value.
* @return false
if this is a failure or returns the result of the application of the given
* function to the success value.
*/
public boolean exists(final F f) {
return e.right().exists(f);
}
@Override
public boolean equals(Object other) {
return Equal.equals0(Validation.class, this, other, () -> Equal.validationEqual(Equal.anyEqual(), Equal.anyEqual()));
}
@Override
public int hashCode() {
return Hash.validationHash(Hash.anyHash(), Hash.anyHash()).hash(this);
}
/**
* Returns a single element list if this is a success value, otherwise an empty list.
*
* @return A single element list if this is a success value, otherwise an empty list.
*/
public List toList() {
return e.right().toList();
}
/**
* Returns the success value in Some
if there is one, otherwise None
.
*
* @return The success value in Some
if there is one, otherwise None
.
*/
public Option toOption() {
return e.right().toOption();
}
/**
* Returns a single element array if this is a success value, otherwise an empty list.
*
* @return A single element array if this is a success value, otherwise an empty list.
*/
public Array toArray() {
return e.right().toArray();
}
/**
* Returns a single element stream if this is a success value, otherwise an empty list.
*
* @return A single element stream if this is a success value, otherwise an empty list.
*/
public Stream toStream() {
return e.right().toStream();
}
/**
* 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.
*
* @param s The semigroup to accumulate errors with if
* @param v The validating function to apply.
* @return A failing validation if this or the given validation failed (with errors accumulated if both) or a
* succeeding validation if both succeeded.
*/
@SuppressWarnings({"unchecked"})
public Validation accumapply(final Semigroup s, final Validation> v) {
return isFail() ?
Validation.fail(v.isFail() ?
s.sum(v.fail(), fail()) :
fail()) :
v.isFail() ?
Validation.fail(v.fail()) :
Validation.success(v.success().f(success()));
}
/**
* 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va, final F> f) {
return va.accumapply(s, map(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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va, final F2 f) {
return va.accumapply(s, map(curry(f)));
}
/**
* Accumulates errors anonymously.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @return A Some
if one or more validations failed (accumulated with the semigroup), otherwise,
* None
.
*/
public Option accumulate(final Semigroup s, final Validation va) {
return accumulate(s, va, (t, a) -> unit()).f().toOption();
}
/**
* 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final F>> f) {
return vb.accumapply(s, accumulate(s, va, 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final F3 f) {
return vb.accumapply(s, accumulate(s, va, curry(f)));
}
/**
* Accumulates errors anonymously.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @return A Some
if one or more validations failed (accumulated with the semigroup), otherwise,
* None
.
*/
public Option accumulate(final Semigroup s, final Validation va, final Validation vb) {
return accumulate(s, va, vb, (t, a, b) -> unit()).f().toOption();
}
/**
* 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final F>>> f) {
return vc.accumapply(s, accumulate(s, va, vb, 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final F4 f) {
return vc.accumapply(s, accumulate(s, va, vb, curry(f)));
}
/**
* Accumulates errors anonymously.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @return A Some
if one or more validations failed (accumulated with the semigroup), otherwise,
* None
.
*/
public Option accumulate(final Semigroup s, final Validation va, final Validation vb,
final Validation vc) {
return accumulate(s, va, vb, vc, (t, a, b, c) -> unit()).f().toOption();
}
/**
* 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd,
final F>>>> f) {
return vd.accumapply(s, accumulate(s, va, vb, vc, 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd, final F5 f) {
return vd.accumapply(s, accumulate(s, va, vb, vc, curry(f)));
}
/**
* Accumulates errors anonymously.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @return A Some
if one or more validations failed (accumulated with the semigroup), otherwise,
* None
.
*/
public Option accumulate(final Semigroup s, final Validation va, final Validation vb,
final Validation vc, final Validation vd) {
return accumulate(s, va, vb, vc, vd, (t, a, b, c, d) -> unit()).f().toOption();
}
/**
* 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param ve The sixth validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd, final Validation ve,
final F>>>>> f) {
return ve.accumapply(s, accumulate(s, va, vb, vc, vd, 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param ve The sixth validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd, final Validation ve,
final F6 f) {
return ve.accumapply(s, accumulate(s, va, vb, vc, vd, curry(f)));
}
/**
* Accumulates errors anonymously.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param ve The sixth validation to accumulate errors with if it failed.
* @return A Some
if one or more validations failed (accumulated with the semigroup), otherwise,
* None
.
*/
public Option accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd, final Validation ve) {
return accumulate(s, va, vb, vc, vd, ve, (t, a, b, c, d, e1) -> unit()).f().toOption();
}
/**
* 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param ve The sixth validation to accumulate errors with if it failed.
* @param vf The seventh validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd, final Validation ve,
final Validation vf,
final F>>>>>> f) {
return vf.accumapply(s, accumulate(s, va, vb, vc, vd, ve, 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param ve The sixth validation to accumulate errors with if it failed.
* @param vf The seventh validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd, final Validation ve,
final Validation vf,
final F7 f) {
return vf.accumapply(s, accumulate(s, va, vb, vc, vd, ve, curry(f)));
}
/**
* Accumulates errors anonymously.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param ve The sixth validation to accumulate errors with if it failed.
* @param vf The seventh validation to accumulate errors with if it failed.
* @return A Some
if one or more validations failed (accumulated with the semigroup), otherwise,
* None
.
*/
public Option accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd, final Validation ve,
final Validation vf) {
return accumulate(s, va, vb, vc, vd, ve, vf, (t, a, b, c, d, e1, f) -> unit()).f().toOption();
}
/**
* 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param ve The sixth validation to accumulate errors with if it failed.
* @param vf The seventh validation to accumulate errors with if it failed.
* @param vg The eighth validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd, final Validation ve,
final Validation vf, final Validation vg,
final F>>>>>>> f) {
return vg.accumapply(s, accumulate(s, va, vb, vc, vd, ve, vf, 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.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param ve The sixth validation to accumulate errors with if it failed.
* @param vf The seventh validation to accumulate errors with if it failed.
* @param vg The eighth validation to accumulate errors with if it failed.
* @param f The function to apply if all validations have succeeded.
* @return A succeeding validation if all validations succeeded, or a failing validation with errors accumulated if
* one or more failed.
*/
public Validation accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd, final Validation ve,
final Validation vf, final Validation vg,
final F8 f) {
return vg.accumapply(s, accumulate(s, va, vb, vc, vd, ve, vf, curry(f)));
}
/**
* Accumulates errors anonymously.
*
* @param s The semigroup to accumulate errors with if one or more validations fail.
* @param va The second validation to accumulate errors with if it failed.
* @param vb The third validation to accumulate errors with if it failed.
* @param vc The fourth validation to accumulate errors with if it failed.
* @param vd The fifth validation to accumulate errors with if it failed.
* @param ve The sixth validation to accumulate errors with if it failed.
* @param vf The seventh validation to accumulate errors with if it failed.
* @param vg The eighth validation to accumulate errors with if it failed.
* @return A Some
if one or more validations failed (accumulated with the semigroup), otherwise,
* None
.
*/
public Option accumulate(final Semigroup s, final Validation va,
final Validation vb, final Validation vc,
final Validation vd, final Validation ve,
final Validation vf, final Validation vg) {
return accumulate(s, va, vb, vc, vd, ve, vf, vg, (t, a, b, c, d, e1, f, g) -> unit()).f().toOption();
}
/**
* Returns an iterator for this validation. This method exists to permit the use in a for
-each loop.
*
* @return A iterator for this validation.
*/
public Iterator iterator() {
return toEither().right().iterator();
}
public Validation, T> accumulate() {
if (isFail()) {
return Validation.fail(List.single(fail()));
} else {
return Validation.success(success());
}
}
public Validation, B> accumulate(F f) {
if (isFail()) {
return Validation.fail(List.single(fail()));
} else {
return Validation.success(f.f(success()));
}
}
public Validation, C> accumulate(Validation v2, F2 f) {
List list = List.nil();
if (isFail()) {
list = list.cons(fail());
}
if (v2.isFail()) {
list = list.cons(v2.fail());
}
if (!list.isEmpty()) {
return Validation.fail(list);
} else {
return Validation.success(f.f(success(), v2.success()));
}
}
public Validation, D> accumulate(Validation v2, Validation v3, F3 f) {
List list = fails(list(this, v2, v3));
if (!list.isEmpty()) {
return Validation.fail(list);
} else {
return Validation.success(f.f(success(), v2.success(), v3.success()));
}
}
public Validation, E> accumulate(Validation v2, Validation v3, Validation v4, F4 f) {
List list = fails(list(this, v2, v3, v4));
if (!list.isEmpty()) {
return Validation.fail(list);
} else {
return Validation.success(f.f(success(), v2.success(), v3.success(), v4.success()));
}
}
public Validation, $F> accumulate(Validation v2, Validation