Class ResultTErrorEnsureExtensions
- Namespace
- REslava.Result.Extensions
- Assembly
- REslava.Result.dll
Ensure and EnsureAsync overloads for Result<TValue, TError> typed pipelines.
Each overload widens the error union by one slot when the predicate fails — same growth
pattern as Bind:
- Overload 1 — first guard on a single-error result:
Result<T,T1> + T2 → Result<T, ErrorsOf<T1,T2>> - Overloads 2–7 — grow an existing
ErrorsOfunion by one slot per guard.
public static class ResultTErrorEnsureExtensions
- Inheritance
-
ResultTErrorEnsureExtensions
- Inherited Members
Methods
EnsureAsync<TValue, T1, T2>(Result<TValue, T1>, Func<TValue, Task<bool>>, T2)
Async variant of Ensure<TValue, T1, T2>(Result<TValue, T1>, Func<TValue, bool>, T2). The predicate is awaited; the result itself is evaluated synchronously.
public static Task<Result<TValue, ErrorsOf<T1, T2>>> EnsureAsync<TValue, T1, T2>(this Result<TValue, T1> result, Func<TValue, Task<bool>> predicate, T2 error) where T1 : IError where T2 : IError
Parameters
Returns
Type Parameters
TValueT1T2
EnsureAsync<TValue, T1, T2, T3>(Result<TValue, ErrorsOf<T1, T2>>, Func<TValue, Task<bool>>, T3)
Async variant that grows a 2-slot error union by one slot.
public static Task<Result<TValue, ErrorsOf<T1, T2, T3>>> EnsureAsync<TValue, T1, T2, T3>(this Result<TValue, ErrorsOf<T1, T2>> result, Func<TValue, Task<bool>> predicate, T3 error) where T1 : IError where T2 : IError where T3 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3
EnsureAsync<TValue, T1, T2, T3, T4>(Result<TValue, ErrorsOf<T1, T2, T3>>, Func<TValue, Task<bool>>, T4)
Async variant that grows a 3-slot error union by one slot.
public static Task<Result<TValue, ErrorsOf<T1, T2, T3, T4>>> EnsureAsync<TValue, T1, T2, T3, T4>(this Result<TValue, ErrorsOf<T1, T2, T3>> result, Func<TValue, Task<bool>> predicate, T4 error) where T1 : IError where T2 : IError where T3 : IError where T4 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3T4
EnsureAsync<TValue, T1, T2, T3, T4, T5>(Result<TValue, ErrorsOf<T1, T2, T3, T4>>, Func<TValue, Task<bool>>, T5)
Async variant that grows a 4-slot error union by one slot.
public static Task<Result<TValue, ErrorsOf<T1, T2, T3, T4, T5>>> EnsureAsync<TValue, T1, T2, T3, T4, T5>(this Result<TValue, ErrorsOf<T1, T2, T3, T4>> result, Func<TValue, Task<bool>> predicate, T5 error) where T1 : IError where T2 : IError where T3 : IError where T4 : IError where T5 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3T4T5
EnsureAsync<TValue, T1, T2, T3, T4, T5, T6>(Result<TValue, ErrorsOf<T1, T2, T3, T4, T5>>, Func<TValue, Task<bool>>, T6)
Async variant that grows a 5-slot error union by one slot.
public static Task<Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6>>> EnsureAsync<TValue, T1, T2, T3, T4, T5, T6>(this Result<TValue, ErrorsOf<T1, T2, T3, T4, T5>> result, Func<TValue, Task<bool>> predicate, T6 error) where T1 : IError where T2 : IError where T3 : IError where T4 : IError where T5 : IError where T6 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3T4T5T6
EnsureAsync<TValue, T1, T2, T3, T4, T5, T6, T7>(Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6>>, Func<TValue, Task<bool>>, T7)
Async variant that grows a 6-slot error union by one slot.
public static Task<Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6, T7>>> EnsureAsync<TValue, T1, T2, T3, T4, T5, T6, T7>(this Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6>> result, Func<TValue, Task<bool>> predicate, T7 error) where T1 : IError where T2 : IError where T3 : IError where T4 : IError where T5 : IError where T6 : IError where T7 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3T4T5T6T7
EnsureAsync<TValue, T1, T2, T3, T4, T5, T6, T7, T8>(Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6, T7>>, Func<TValue, Task<bool>>, T8)
Async variant that grows a 7-slot error union by one slot — maximum union size (T8).
public static Task<Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6, T7, T8>>> EnsureAsync<TValue, T1, T2, T3, T4, T5, T6, T7, T8>(this Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6, T7>> result, Func<TValue, Task<bool>> predicate, T8 error) where T1 : IError where T2 : IError where T3 : IError where T4 : IError where T5 : IError where T6 : IError where T7 : IError where T8 : IError
Parameters
resultResult<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6, T7>>predicateFunc<TValue, Task<bool>>errorT8
Returns
Type Parameters
TValueT1T2T3T4T5T6T7T8
Ensure<TValue, T1, T2>(Result<TValue, T1>, Func<TValue, bool>, T2)
Adds a guard to a single-error result, widening to a 2-slot error union when the guard fails.
Use this as the first Ensure in a typed pipeline.
public static Result<TValue, ErrorsOf<T1, T2>> Ensure<TValue, T1, T2>(this Result<TValue, T1> result, Func<TValue, bool> predicate, T2 error) where T1 : IError where T2 : IError
Parameters
Returns
Type Parameters
TValueT1T2
Examples
Result<Order, ValidationError> result = Validate(req);
// Guard: widen to ErrorsOf<ValidationError, CreditLimitError>
result.Ensure(o => o.Amount > 0, new CreditLimitError("Credit limit exceeded"));
Ensure<TValue, T1, T2, T3>(Result<TValue, ErrorsOf<T1, T2>>, Func<TValue, bool>, T3)
Grows a 2-slot error union by one slot when the guard fails.
public static Result<TValue, ErrorsOf<T1, T2, T3>> Ensure<TValue, T1, T2, T3>(this Result<TValue, ErrorsOf<T1, T2>> result, Func<TValue, bool> predicate, T3 error) where T1 : IError where T2 : IError where T3 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3
Ensure<TValue, T1, T2, T3, T4>(Result<TValue, ErrorsOf<T1, T2, T3>>, Func<TValue, bool>, T4)
Grows a 3-slot error union by one slot when the guard fails.
public static Result<TValue, ErrorsOf<T1, T2, T3, T4>> Ensure<TValue, T1, T2, T3, T4>(this Result<TValue, ErrorsOf<T1, T2, T3>> result, Func<TValue, bool> predicate, T4 error) where T1 : IError where T2 : IError where T3 : IError where T4 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3T4
Ensure<TValue, T1, T2, T3, T4, T5>(Result<TValue, ErrorsOf<T1, T2, T3, T4>>, Func<TValue, bool>, T5)
Grows a 4-slot error union by one slot when the guard fails.
public static Result<TValue, ErrorsOf<T1, T2, T3, T4, T5>> Ensure<TValue, T1, T2, T3, T4, T5>(this Result<TValue, ErrorsOf<T1, T2, T3, T4>> result, Func<TValue, bool> predicate, T5 error) where T1 : IError where T2 : IError where T3 : IError where T4 : IError where T5 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3T4T5
Ensure<TValue, T1, T2, T3, T4, T5, T6>(Result<TValue, ErrorsOf<T1, T2, T3, T4, T5>>, Func<TValue, bool>, T6)
Grows a 5-slot error union by one slot when the guard fails.
public static Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6>> Ensure<TValue, T1, T2, T3, T4, T5, T6>(this Result<TValue, ErrorsOf<T1, T2, T3, T4, T5>> result, Func<TValue, bool> predicate, T6 error) where T1 : IError where T2 : IError where T3 : IError where T4 : IError where T5 : IError where T6 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3T4T5T6
Ensure<TValue, T1, T2, T3, T4, T5, T6, T7>(Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6>>, Func<TValue, bool>, T7)
Grows a 6-slot error union by one slot when the guard fails.
public static Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6, T7>> Ensure<TValue, T1, T2, T3, T4, T5, T6, T7>(this Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6>> result, Func<TValue, bool> predicate, T7 error) where T1 : IError where T2 : IError where T3 : IError where T4 : IError where T5 : IError where T6 : IError where T7 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3T4T5T6T7
Ensure<TValue, T1, T2, T3, T4, T5, T6, T7, T8>(Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6, T7>>, Func<TValue, bool>, T8)
Grows a 7-slot error union by one slot when the guard fails — maximum union size (T8).
public static Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6, T7, T8>> Ensure<TValue, T1, T2, T3, T4, T5, T6, T7, T8>(this Result<TValue, ErrorsOf<T1, T2, T3, T4, T5, T6, T7>> result, Func<TValue, bool> predicate, T8 error) where T1 : IError where T2 : IError where T3 : IError where T4 : IError where T5 : IError where T6 : IError where T7 : IError where T8 : IError
Parameters
Returns
Type Parameters
TValueT1T2T3T4T5T6T7T8