Show / Hide Table of Contents

Class RuleWithParentValueAdapter<TValue, TValidated>

An adapter class for instances of IRule<TValue, TParent>, which allows their logic to be executed as if they were instances of the non-generic IValidationLogic interface.

Inheritance
System.Object
RuleWithParentValueAdapter<TValue, TValidated>
Implements
IValidationLogic
IHasRuleTimeout
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: CSF.Validation.Rules
Assembly: CSF.Validation.dll
Syntax
public class RuleWithParentValueAdapter<TValue, TValidated> : IValidationLogic, IHasRuleTimeout
Type Parameters
Name Description
TValue

The type of value being validated by the current instance.

TValidated

The type of parent object being validated by the current instance.

Constructors

| Improve this Doc View Source

RuleWithParentValueAdapter(IRule<TValue, TValidated>)

Initialises an instance of RuleWithParentValueAdapter<TValue, TValidated> from a specified rule.

Declaration
public RuleWithParentValueAdapter(IRule<TValue, TValidated> wrapped)
Parameters
Type Name Description
IRule<TValue, TValidated> wrapped

The rule logic to be wrapped by the current instance.

Properties

| Improve this Doc View Source

RuleInterface

Gets the type of rule interface that is used by this rule logic.

Declaration
public Type RuleInterface { get; }
Property Value
Type Description
System.Type
Remarks

This will be a closed-generic form of either IRule<TValidated> or IRule<TValue, TParent>.

| Improve this Doc View Source

RuleObject

Gets a reference to the original/raw rule object instance.

Declaration
public object RuleObject { get; }
Property Value
Type Description
System.Object

Methods

| Improve this Doc View Source

GetResultAsync(Object, Object, RuleContext, CancellationToken)

Executes the logic of the validation rule and returns the result.

Declaration
public ValueTask<RuleResult> GetResultAsync(object value, object parentValue, RuleContext context, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
System.Object value

The value which is being validated by the current rule.

System.Object parentValue

An optional 'parent value' to the value being validated by the current rule. This is typically the object from which the value is accessed.

RuleContext context

A validation rule context object.

System.Threading.CancellationToken token

An optional cancellation token to abort the validation process early.

Returns
Type Description
System.Threading.Tasks.ValueTask<RuleResult>

A task which provides the rule result.

| Improve this Doc View Source

GetTimeout()

Gets the timeout value for the current rule.

Declaration
public TimeSpan? GetTimeout()
Returns
Type Description
System.Nullable<System.TimeSpan>

A timespan indicating the timeout duration, or a null reference if no timeout is applicable.

Remarks

If this method returns non-null & the execution of the rule takes longer than this timeout value then:

The rule will immediately return an error result. Additionally the CancellationToken passed to the rule will be cancelled, allowing the rule logic to terminate early.

Implements

IValidationLogic
IHasRuleTimeout
  • Improve this Doc
  • View Source
In This Article
  • Constructors
    • RuleWithParentValueAdapter(IRule<TValue, TValidated>)
  • Properties
    • RuleInterface
    • RuleObject
  • Methods
    • GetResultAsync(Object, Object, RuleContext, CancellationToken)
    • GetTimeout()
  • Implements
Back to top Generated by DocFX