Show / Hide Table of Contents

Interface IConfiguresValueAccessor<TValidated, TValue>

A builder service which configures how a value (retrieved from a different validated object) should be validated.

Namespace: CSF.Validation.ValidatorBuilding
Assembly: CSF.Validation.Abstractions.dll
Syntax
public interface IConfiguresValueAccessor<TValidated, TValue>
Type Parameters
Name Description
TValidated

The type of the validated object.

TValue

The type of the value, retrieved from the TValidated object.

Methods

| Improve this Doc View Source

AccessorExceptionBehaviour(Nullable<ValueAccessExceptionBehaviour>)

Configures the validator with a behaviour to use should the value-accessor for the current value raise an exception..

Declaration
IConfiguresValueAccessor<TValidated, TValue> AccessorExceptionBehaviour(ValueAccessExceptionBehaviour? behaviour)
Parameters
Type Name Description
System.Nullable<ValueAccessExceptionBehaviour> behaviour
Returns
Type Description
IConfiguresValueAccessor<TValidated, TValue>

A reference to the same builder object, enabling chaining of calls if desired.

Remarks

This option will override the behaviour specified at AccessorExceptionBehaviour for the current value, if the specified behaviour is any non-null value. If this method is unused then it will be treated as if the specified ValueAccessExceptionBehaviour specified at this point were null and the AccessorExceptionBehaviour will be used instead.

See Also
AccessorExceptionBehaviour
| Improve this Doc View Source

AddRule<TRule>(Action<IConfiguresRule<TRule>>)

Adds a validation rule to validate the value indicated by the value accessor. The rule type must be a class that implements IRule<TValidated> for the same (or compatible contravariant) generic type TValue.

Declaration
IConfiguresValueAccessor<TValidated, TValue> AddRule<TRule>(Action<IConfiguresRule<TRule>> ruleDefinition = null)
    where TRule : IRule<TValue>
Parameters
Type Name Description
System.Action<IConfiguresRule<TRule>> ruleDefinition

An optional action which defines & configures the validation rule.

Returns
Type Description
IConfiguresValueAccessor<TValidated, TValue>

A reference to the same builder object, enabling chaining of calls if desired.

Type Parameters
Name Description
TRule

The concrete type of the validation rule.

| Improve this Doc View Source

AddRules<TBuilder>()

Adds/imports rules from an object that implements IBuildsValidator<TValidated> for the generic type TValue.

Declaration
IConfiguresValueAccessor<TValidated, TValue> AddRules<TBuilder>()
    where TBuilder : IBuildsValidator<TValue>
Returns
Type Description
IConfiguresValueAccessor<TValidated, TValue>

A reference to the same builder object, enabling chaining of calls if desired.

Type Parameters
Name Description
TBuilder

The type of a class implementing IBuildsValidator<TValidated>, specifying how a validator should be built.

Remarks

This allows composition of validators, reuse of validation rules across differing validation scenarios and additionally the building of validators which operate across complex object graphs. All of the rules specified in the selected builder-type will be imported and added to the current validator, validating the type TValue.

| Improve this Doc View Source

AddRuleWithParent<TRule>(Action<IConfiguresRule<TRule>>)

Adds a "value validation rule" to validate the value & the validated object instance. The rule type must be a class that implements IRule<TValue, TParent> for the same (or compatible contravariant) generic types TValue & TValidated.

Declaration
IConfiguresValueAccessor<TValidated, TValue> AddRuleWithParent<TRule>(Action<IConfiguresRule<TRule>> ruleDefinition = null)
    where TRule : IRule<TValue, TValidated>
Parameters
Type Name Description
System.Action<IConfiguresRule<TRule>> ruleDefinition

An optional action which defines & configures the validation rule.

Returns
Type Description
IConfiguresValueAccessor<TValidated, TValue>

A reference to the same builder object, enabling chaining of calls if desired.

Type Parameters
Name Description
TRule

The concrete type of the validation rule.

| Improve this Doc View Source

WhenValueIs<TDerived>(Action<IConfiguresValueAccessor<TValidated, TDerived>>)

Adds validation configuration for polymorphic validatation when the runtime type of the validated value is TDerived.

Declaration
IConfiguresValueAccessor<TValidated, TValue> WhenValueIs<TDerived>(Action<IConfiguresValueAccessor<TValidated, TDerived>> derivedConfig)
    where TDerived : TValue
Parameters
Type Name Description
System.Action<IConfiguresValueAccessor<TValidated, TDerived>> derivedConfig

Configuration which indicates what validation will be performed upon the value if its runtime type is TDerived.

Returns
Type Description
IConfiguresValueAccessor<TValidated, TValue>

A reference to the same builder object, enabling chaining of calls if desired.

Type Parameters
Name Description
TDerived

The derived (child) type to be configured for validation in this polymorphic validation configuration.

Remarks

Where the current validator configuration works to validate an object of type TValue, the value being validated might be a derived type of TValue at runtime. Polymorphic validation allows a developer to specify how a derived type should be validated, if that is the runtime type of the value to be validated.

This method may be used multiple times, each time for a different type that is derived from TValue.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX