/// <inheritdoc/> public async Task <IReadOnlyCollection <ValidationRuleResult> > ExecuteAllRulesAsync(IRuleExecutionContext executionContext, CancellationToken cancellationToken = default) { var results = (await wrapped.ExecuteAllRulesAsync(executionContext, cancellationToken).ConfigureAwait(false)).ToList(); cancellationToken.ThrowIfCancellationRequested(); var resultsForRulesWithFailedDependencies = executionContext .GetRulesWhoseDependenciesHaveFailed() .Select(x => new ValidationRuleResult(x.Result, contextFactory.GetRuleContext(x), x.RuleLogic)); results.AddRange(resultsForRulesWithFailedDependencies); return(results); }
/// <inheritdoc/> public async Task <IReadOnlyCollection <ValidationRuleResult> > ExecuteAllRulesAsync(IRuleExecutionContext executionContext, CancellationToken cancellationToken = default) { var results = (await wrapped.ExecuteAllRulesAsync(executionContext, cancellationToken).ConfigureAwait(false)).ToList(); cancellationToken.ThrowIfCancellationRequested(); var extraResultsForFailedValues = executionContext.AllRules .Select(x => x.ExecutableRule.ValidatedValue.ValueResponse) .OfType <ErrorGetValueToBeValidatedResponse>() .Distinct() .Select(x => new ValidationRuleResult(new RuleResult(RuleOutcome.Errored, exception: x.Exception), null, null)) .ToList(); results.AddRange(extraResultsForFailedValues); return(results); }