Class ValidationRuleSet<TModel>
- Namespace
- EncDotNet.S100.Validation
- Assembly
- EncDotNet.S100.Core.dll
A composable, ordered collection of IValidationRule<TModel>
for the same typed data model. Each per-spec library exposes a default
rule set via a static SxxxRules.Default() factory; consumers may
build custom sets by adding, removing, or replacing rules.
public sealed class ValidationRuleSet<TModel>
Type Parameters
TModelThe typed data-model type the rules operate on.
- Inheritance
-
ValidationRuleSet<TModel>
- Inherited Members
Constructors
ValidationRuleSet(params IValidationRule<TModel>[])
Creates a rule set from the supplied rules.
public ValidationRuleSet(params IValidationRule<TModel>[] rules)
Parameters
rulesIValidationRule<TModel>[]
ValidationRuleSet(IEnumerable<IValidationRule<TModel>>)
Creates a rule set from the supplied rules.
public ValidationRuleSet(IEnumerable<IValidationRule<TModel>> rules)
Parameters
rulesIEnumerable<IValidationRule<TModel>>
Properties
Empty
An empty rule set — evaluating it always returns Empty.
public static ValidationRuleSet<TModel> Empty { get; }
Property Value
- ValidationRuleSet<TModel>
Rules
The rules in this set, in evaluation order.
public IReadOnlyList<IValidationRule<TModel>> Rules { get; }
Property Value
- IReadOnlyList<IValidationRule<TModel>>
Methods
Add(IValidationRule<TModel>)
Returns a new rule set with rule appended.
public ValidationRuleSet<TModel> Add(IValidationRule<TModel> rule)
Parameters
ruleIValidationRule<TModel>
Returns
- ValidationRuleSet<TModel>
Remove(string)
Returns a new rule set with every rule whose RuleId
equals ruleId removed.
public ValidationRuleSet<TModel> Remove(string ruleId)
Parameters
ruleIdstring
Returns
- ValidationRuleSet<TModel>
Run(TModel, ValidationContext?)
Evaluates every rule in this set against model and
returns the aggregated ValidationReport. All rules are
evaluated regardless of any errors found by earlier rules (lint-pass
semantics). Exceptions thrown from a rule are caught and surfaced as
a synthetic Error finding so that a
single faulty rule cannot abort the report.
public ValidationReport Run(TModel model, ValidationContext? context = null)
Parameters
modelTModelcontextValidationContext