Class RuleBuilderOptionsExtensions

Namespace
Cratis.Arc.Validation
Assembly
Cratis.Arc.Core.dll

Extensions for working with FluentValidation.IRuleBuilderOptions<T, TProperty>.

public static class RuleBuilderOptionsExtensions
Inheritance
RuleBuilderOptionsExtensions
Inherited Members

Methods

WhenCommand<T, TProperty>(IRuleBuilderOptions<T, TProperty>, ApplyConditionTo)

Specifies a condition for when the context is a command.

public static IRuleBuilderOptions<T, TProperty> WhenCommand<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, ApplyConditionTo applyConditionTo = ApplyConditionTo.AllValidators)

Parameters

rule IRuleBuilderOptions<T, TProperty>

The current rule.

applyConditionTo ApplyConditionTo

Whether the condition should be applied to the current rule or all rules in the chain. Default: All.

Returns

IRuleBuilderOptions<T, TProperty>

An IRuleBuilder instance on which validators can be defined.

Type Parameters

T

Type of object being validated.

TProperty

Property type.

WhenQuery<T, TProperty>(IRuleBuilderOptions<T, TProperty>, ApplyConditionTo)

Specifies a condition for when the context is a query.

public static IRuleBuilderOptions<T, TProperty> WhenQuery<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, ApplyConditionTo applyConditionTo = ApplyConditionTo.AllValidators)

Parameters

rule IRuleBuilderOptions<T, TProperty>

The current rule.

applyConditionTo ApplyConditionTo

Whether the condition should be applied to the current rule or all rules in the chain. Default: All.

Returns

IRuleBuilderOptions<T, TProperty>

An IRuleBuilder instance on which validators can be defined.

Type Parameters

T

Type of object being validated.

TProperty

Property type.

WithSeverity<T, TProperty>(IRuleBuilderOptions<T, TProperty>, ValidationResultSeverity)

Sets the severity level for the validation rule.

public static IRuleBuilderOptions<T, TProperty> WithSeverity<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, ValidationResultSeverity severity)

Parameters

rule IRuleBuilderOptions<T, TProperty>

The current rule.

severity ValidationResultSeverity

The ValidationResultSeverity to set.

Returns

IRuleBuilderOptions<T, TProperty>

An IRuleBuilder instance on which validators can be defined.

Type Parameters

T

Type of object being validated.

TProperty

Property type.

WithState<T, TProperty>(IRuleBuilderOptions<T, TProperty>, object)

Sets custom state for the validation rule.

public static IRuleBuilderOptions<T, TProperty> WithState<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, object state)

Parameters

rule IRuleBuilderOptions<T, TProperty>

The current rule.

state object

The state object to associate with the validation result.

Returns

IRuleBuilderOptions<T, TProperty>

An IRuleBuilder instance on which validators can be defined.

Type Parameters

T

Type of object being validated.

TProperty

Property type.