Table of Contents

Class EnsureAllExtensions

Namespace
Trellis
Assembly
Trellis.Results.dll

Provides extension methods for ensuring multiple conditions on Result values simultaneously. Unlike Ensure<TValue>(Result<TValue>, Func<TValue, bool>, Error) which short-circuits on the first failure, EnsureAll runs ALL checks and accumulates errors into a single combined error.

public static class EnsureAllExtensions
Inheritance
EnsureAllExtensions
Inherited Members

Remarks

This is the "applicative" validation style — validate everything, merge errors. Useful for form validation where users need to see all errors at once.

Methods

EnsureAll<TValue>(Result<TValue>, params (Func<TValue, bool> predicate, Error error)[])

Runs all validation checks on the result value and accumulates any failures into a single error. If the result is already a failure, it is returned unchanged.

public static Result<TValue> EnsureAll<TValue>(this Result<TValue> result, params (Func<TValue, bool> predicate, Error error)[] checks)

Parameters

result Result<TValue>

The result to validate.

checks (Func<TValue, bool> predicate, Error error)[]

The validation checks to run, each consisting of a predicate and an error to use if the predicate fails.

Returns

Result<TValue>

The original result if all checks pass; otherwise a failure with all accumulated errors.

Type Parameters

TValue

Type of the result value.