public static Task <OperationResult> RequireOnSuccessAsync(this OperationResult currentOperationResult, AsyncPredicate condition, AsyncFunc <IOperationError> errorBuilder) => currentOperationResult .DoOnSuccessWhenAsync(async() => !await condition.AssertNotNull(nameof(condition)) .Invoke(), async() => OperationResult.FromError(await errorBuilder.AssertNotNull(nameof(errorBuilder)) .Invoke()));
public static Task <OperationResult <T> > RequireOnSuccessAsync <T>(this OperationResult <T> currentOperationResult, bool condition, AsyncFunc <T, IOperationError> errorBuilder) => currentOperationResult .DoOnSuccessWhenAsync(!condition, async(T x) => OperationResult.FromError(await errorBuilder.AssertNotNull(nameof(errorBuilder)) .Invoke(x)));
public static Task <OperationResult <T> > RequireOnSuccessAsync <T>(this OperationResult <T> currentOperationResult, AsyncPredicate <T> condition, Func <T, IOperationError> errorBuilder) => currentOperationResult .DoOnSuccessWhenAsync(async x => !await condition.AssertNotNull(nameof(condition)) .Invoke(x), x => (FunctionalResults.OperationResult)FunctionalResults.OperationResult.FromError(errorBuilder.AssertNotNull(nameof(errorBuilder)) .Invoke(x)));