Class RuleBuilder<TRule>
A builder which is used to define & configure a single instance of a validation rule.
Inheritance
Inherited Members
Namespace: CSF.Validation.ValidatorBuilding
Assembly: CSF.Validation.dll
Syntax
public class RuleBuilder<TRule> : IConfiguresRule<TRule>, IConfiguresContext
Type Parameters
Name | Description |
---|---|
TRule | The concrete type of the configured validation rule. |
Constructors
| Improve this Doc View SourceRuleBuilder(IGetsManifestRuleIdentifierFromRelativeIdentifier, IGetsManifestRuleIdentifier)
Initialises an instance of RuleBuilder<TRule>.
Declaration
public RuleBuilder(IGetsManifestRuleIdentifierFromRelativeIdentifier relativeToManifestIdentityConverter, IGetsManifestRuleIdentifier identifierFactory)
Parameters
Type | Name | Description |
---|---|---|
IGetsManifestRuleIdentifierFromRelativeIdentifier | relativeToManifestIdentityConverter | A service which converts relative rule identifiers to absolute ones. |
IGetsManifestRuleIdentifier | identifierFactory | A factory which creates manifest identifiers. |
Properties
| Improve this Doc View SourceDependencies
Gets or sets a collection of the relative identifiers of other validation rules upon which the current rule depends.
Declaration
public ICollection<RelativeRuleIdentifier> Dependencies { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<RelativeRuleIdentifier> |
Remarks
Validation rule dependencies work in two ways:
- The current rule will not be executed until all of its dependencies have been executed.
- If any of the current rule's dependencies does not complete with a Passed outcome then the current rule's execution will be skipped and automatically recorded as having a DependencyFailed outcome.
In case it is not obvious, specifying a circular set of validation rule dependencies is not allowed.
Name
Gets or sets an optional rule name. This may be used to differentiate different instances of the same rule (but with different configuration), applied to the same member or validated object.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceConfigureContext(ValidatorBuilderContext)
Performs configuration upon the context.
Declaration
public void ConfigureContext(ValidatorBuilderContext context)
Parameters
Type | Name | Description |
---|---|---|
ValidatorBuilderContext | context | The builder context to configure. |
ConfigureRule(Action<TRule>)
Specifies an action to be executed in order to configure the rule before it is executed.
Declaration
public void ConfigureRule(Action<TRule> ruleConfig)
Parameters
Type | Name | Description |
---|---|---|
System.Action<TRule> | ruleConfig | The rule configuration action. |