Interface IExecutesAllRules
An object which executes all of the validation rules using an async API and returns a collection of results.
Namespace: CSF.Validation.RuleExecution
Assembly: CSF.Validation.Abstractions.dll
Syntax
public interface IExecutesAllRules
Remarks
The IRuleExecutionContext provides a context/updating information which indicates which rules are ready to be executed at each given point in the process. Implementors of this interface should use GetRulesWhichMayBeExecuted() in order to retrieve a collection of rules which are ready for immediate execution.
As each rule completes, regardless of its outcome, the HandleValidationRuleResult(ExecutableRule) method should be executed with that rule in order to update the context, such that future usages of GetRulesWhichMayBeExecuted() may return additional rules which are newly-available for execution. The HandleValidationRuleResult(ExecutableRule) method also ensures that alrady-executed rules will not be returned again from GetRulesWhichMayBeExecuted().
This process may be repeated more than once, getting available rules, executing them and updating them in the context. The process should stop when all available rules have been executed (and updated in the context) and GetRulesWhichMayBeExecuted() returns an empty result. This is the point at which validation cannot proceed any further. It might mean that validation is complete or it might mean that one or more rules have failed dependencies or that their validated values threw an exception when they were retrieved (if the AccessorExceptionBehaviour is set to TreatAsError).
Methods
| Improve this Doc View SourceExecuteAllRulesAsync(IRuleExecutionContext, CancellationToken)
Execute all of the specified validation rules and return their results.
Declaration
Task<IReadOnlyCollection<ValidationRuleResult>> ExecuteAllRulesAsync(IRuleExecutionContext executionContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IRuleExecutionContext | executionContext | The validation rule execution context. |
System.Threading.CancellationToken | cancellationToken | An optional cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyCollection<ValidationRuleResult>> | A task containing a collection of the results from the executed validation rules. |