`Ensure` — Guard with Union Widening (v1.39.0)
Ensure adds a guard condition. Each call widens the error union by one slot when the predicate fails:
Result<Order, ValidationError> Validate(CheckoutRequest req) => ...
// First Ensure: Result<Order, ValidationError>
// → Result<Order, ErrorsOf<ValidationError, CreditLimitError>>
var guarded = Validate(request)
.Ensure(order => order.Amount > 0, new CreditLimitError("Amount must be positive"))
.Ensure(order => order.Amount < 10_000, new CreditLimitError("Amount exceeds limit"));
// EnsureAsync — predicate is async
var asyncGuarded = await result
.EnsureAsync(order => CheckCreditAsync(order), new CreditLimitError("Credit check failed"));