public static OperationResult RequireOnSuccess(this OperationResult currentOperationResult, bool condition, Func <IOperationError> errorBuilder) => currentOperationResult .DoOnSuccessWhen(!condition, () => OperationResult.FromError(errorBuilder.AssertNotNull(nameof(errorBuilder)) .Invoke()));
public static OperationResult <T> RequireOnSuccess <T>(this OperationResult <T> currentOperationResult, Predicate <T> condition, Func <T, IOperationError> errorBuilder) => currentOperationResult .DoOnSuccessWhen(x => !condition.AssertNotNull(nameof(condition)) .Invoke(x), x => OperationResult.FromError(errorBuilder.AssertNotNull(nameof(errorBuilder)) .Invoke(x)));