Table of Contents

Class ValidationRule<T>

Namespace
The.Values
Assembly
Instagile.dll

Validation rule which uses a Rule function (sync or async) to evaluate

public sealed class ValidationRule<T> : IValidationRule where T : IHasChanges

Type Parameters

T

The type of the value of the field being validated

Inheritance
ValidationRule<T>
Implements
Inherited Members

Constructors

ValidationRule(AsyncRule<T>, ValidationScope?)

public ValidationRule(AsyncRule<T> rule, ValidationScope? scope = null)

Parameters

rule AsyncRule<T>
scope ValidationScope

ValidationRule(Rule<T>, ValidationScope?)

public ValidationRule(Rule<T> rule, ValidationScope? scope = null)

Parameters

rule Rule<T>
scope ValidationScope

Properties

IsAsyncRule

public bool IsAsyncRule { get; }

Property Value

bool

Scope

public ValidationScope Scope { get; }

Property Value

ValidationScope

Methods

Evaluate(IValidatable)

Evaluates the validation rule (synchronously) and returns the result (including result type and message)

public ValidationResult Evaluate(IValidatable subject)

Parameters

subject IValidatable

The field being validated using this rule

Returns

ValidationResult

ValidationResult

Exceptions

InvalidOperationException

If this rule is an async rule, an InvalidOperationException will be thrown.

ArgumentException

If the subject argument provided is not an IValidatable of the expected type, an ArgumentException will be thrown

EvaluateAsync(IValidatable)

Evaluates the validation rule (asynchronously) and returns the result (including result type and message)

public Task<ValidationResult> EvaluateAsync(IValidatable subject)

Parameters

subject IValidatable

The field being validated using this rule

Returns

Task<ValidationResult>

ValidationResult

Remarks

A synchronous rule may be evaluated using EvaluateAsync, but it will be evaluated synchronously

Exceptions

ArgumentException

If the subject argument provided is not an IValidatable of the expected type, an ArgumentException will be thrown