Interface Validated.Accumulator<E>
public static interface Validated.Accumulator<E>
The binding handle passed to
Validated.accumulate(Function).
Both on overloads are error-covariant: an Accumulator<BankError>
accepts Validated<NoSuchAccount, …> and Result<WrongPin, …> where
each subtype implements BankError, unifying per-step error subtypes into the
block's E with no per-step mapErr. See ADR-11.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidCheck a condition with no value to bind: a guard, a limit, a cross-field rule.default <T> Validated.Bound<T> Bind aResult:Erraccumulates as a single error.<T> Validated.Bound<T> Bind aValidated: aValid's value becomes available viaValidated.Bound.value(); anInvalid's errors are added to the accumulator.default <T> Validated.Bound<T> Bind anOptional: empty accumulatesifEmpty.get().default <T,R> Validated.Bound <List<R>> Bind a validation of every element of a list (onof atraverse): every failing element contributes its errors, and theValidated.Boundyields the fully-parsed list.
-
Method Details
-
on
Bind aValidated: aValid's value becomes available viaValidated.Bound.value(); anInvalid's errors are added to the accumulator. Binding never aborts the block; later validations still run.The error is consumed covariantly (
? extends E), so steps that return aValidatedwith an error subtype are accepted withoutmapErr. -
on
Bind aResult:Erraccumulates as a single error.The error is consumed covariantly (
? extends E), so steps that return aResultwith an error subtype are accepted withoutmapErr. -
on
Bind anOptional: empty accumulatesifEmpty.get(). -
onEach
default <T,R> Validated.Bound<List<R>> onEach(List<? extends T> items, Function<? super T, ? extends Validated<E, R>> parse) Bind a validation of every element of a list (onof atraverse): every failing element contributes its errors, and theValidated.Boundyields the fully-parsed list. -
ensure
-