Table of Contents

Class RuleSetBuilder<T>

Namespace
JD.Domain.Rules
Assembly
JD.Domain.Rules.dll

Fluent builder for constructing rule sets.

public sealed class RuleSetBuilder<T> where T : class

Type Parameters

T

The 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

name string

The 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

ruleSetName string

The 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

id string

The unique identifier for the rule.

predicate Expression<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

id string

The unique identifier for the rule.

predicate Expression<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

key string

The metadata key.

value object

The metadata value.

Returns

RuleSetBuilder<T>

The rule set builder for chaining.