Class RuleBuilder<T>
Fluent builder for configuring individual rules.
public sealed class RuleBuilder<T> where T : class
Type Parameters
TThe entity type.
- Inheritance
-
RuleBuilder<T>
- Inherited Members
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.
Invariant(string, Expression<Func<T, bool>>)
Adds another invariant rule to the rule set.
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 to the rule set.
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.
WithMessage(string)
Sets the error message for rule violations.
public RuleBuilder<T> WithMessage(string message)
Parameters
messagestringThe error message.
Returns
- RuleBuilder<T>
The rule builder for chaining.
WithMetadata(string, object?)
Adds metadata to the rule.
public RuleBuilder<T> WithMetadata(string key, object? value)
Parameters
Returns
- RuleBuilder<T>
The rule builder for chaining.
WithSeverity(RuleSeverity)
Sets the severity of rule violations.
public RuleBuilder<T> WithSeverity(RuleSeverity severity)
Parameters
severityRuleSeverityThe severity level.
Returns
- RuleBuilder<T>
The rule builder for chaining.
WithTag(string)
Adds a tag to the rule for categorization.
public RuleBuilder<T> WithTag(string tag)
Parameters
tagstringThe tag to add.
Returns
- RuleBuilder<T>
The rule builder for chaining.