Class RuleSetBuilder<T>
Fluent builder for constructing rule sets.
public sealed class RuleSetBuilder<T> where T : class
Type Parameters
TThe entity type this rule set applies to.
- Inheritance
-
RuleSetBuilder<T>
- Inherited Members
Constructors
RuleSetBuilder()
Initializes a new instance of the RuleSetBuilder<T> class with default name.
public RuleSetBuilder()
RuleSetBuilder(string)
Initializes a new instance of the RuleSetBuilder<T> class with the specified name.
public RuleSetBuilder(string name)
Parameters
namestringThe name of the rule set.
Methods
Build()
Builds the rule set manifest.
public RuleSetManifest Build()
Returns
- RuleSetManifest
The constructed rule set manifest.
BuildCompiled()
Builds a compiled rule set that can be evaluated at runtime.
public CompiledRuleSet<T> BuildCompiled()
Returns
- CompiledRuleSet<T>
The compiled rule set.
Include(string)
Includes another rule set by name.
public RuleSetBuilder<T> Include(string ruleSetName)
Parameters
ruleSetNamestringThe name of the rule set to include.
Returns
- RuleSetBuilder<T>
The rule set builder for chaining.
Invariant(string, Expression<Func<T, bool>>)
Adds an invariant rule that must always be true.
public RuleBuilder<T> Invariant(string id, Expression<Func<T, bool>> predicate)
Parameters
idstringThe unique identifier for the rule.
predicateExpression<Func<T, bool>>The rule predicate expression.
Returns
- RuleBuilder<T>
A rule builder for further configuration.
Validator(string, Expression<Func<T, bool>>)
Adds a validator rule for input validation.
public RuleBuilder<T> Validator(string id, Expression<Func<T, bool>> predicate)
Parameters
idstringThe unique identifier for the rule.
predicateExpression<Func<T, bool>>The rule predicate expression.
Returns
- RuleBuilder<T>
A rule builder for further configuration.
WithMetadata(string, object?)
Adds metadata to the rule set.
public RuleSetBuilder<T> WithMetadata(string key, object? value)
Parameters
Returns
- RuleSetBuilder<T>
The rule set builder for chaining.