Show / Hide Table of Contents

Class Validator<TValidated>

The validator service, which validates instances of TValidated and returns a result.

Inheritance
System.Object
Validator<TValidated>
Implements
IValidator<TValidated>
IValidator
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
Assembly: CSF.Validation.dll
Syntax
public class Validator<TValidated> : IValidator<TValidated>, IValidator
Type Parameters
Name Description
TValidated

The type of the object which is validated.

Constructors

| Improve this Doc View Source

Validator(ValidationManifest, IGetsRuleExecutor, IGetsAllExecutableRulesWithDependencies, IGetsResolvedValidationOptions, IGetsRuleExecutionContext)

Initialises a new instance of Validator<TValidated>.

Declaration
public Validator(ValidationManifest manifest, IGetsRuleExecutor executorFactory, IGetsAllExecutableRulesWithDependencies ruleFactory, IGetsResolvedValidationOptions optionsResolver, IGetsRuleExecutionContext contextFactory)
Parameters
Type Name Description
ValidationManifest manifest

A validation manifest from which to creator the validator.

IGetsRuleExecutor executorFactory

The rule-executor factory.

IGetsAllExecutableRulesWithDependencies ruleFactory

The rule factory.

IGetsResolvedValidationOptions optionsResolver

An options resolver.

IGetsRuleExecutionContext contextFactory

A rule execution context factory.

Exceptions
Type Condition
System.ArgumentNullException

If any parameter is null.

Properties

| Improve this Doc View Source

ValidatedType

Gets the type of object that this validator is intended to validate.

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

The first parameter to ValidateAsync(Object, ValidationOptions, CancellationToken) must be of either the type indicated by this property, or a type that is derived from the type indicated by this property.

Methods

| Improve this Doc View Source

ValidateAsync(TValidated, ValidationOptions, CancellationToken)

Validate the specified object instance asynchronously and get a validation result.

Declaration
public async Task<IQueryableValidationResult<TValidated>> ValidateAsync(TValidated validatedObject, ValidationOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
TValidated validatedObject

The object to be validated.

ValidationOptions options

An optional object containing configuration options related to the validation process.

System.Threading.CancellationToken cancellationToken

An optional object which enables premature cancellation of the validation process.

Returns
Type Description
System.Threading.Tasks.Task<IQueryableValidationResult<TValidated>>

A task containing the result of the validation process.

Exceptions
Type Condition
ValidationException

If the validation process fails or errors and the RuleThrowingBehaviour of the resolved options indicate that an exception should be thrown. See IGetsResolvedValidationOptions for more info about how the options are resolved from the defaults configured with DI and the options specified here.

Explicit Interface Implementations

| Improve this Doc View Source

IValidator.ValidateAsync(Object, ValidationOptions, CancellationToken)

Declaration
async Task<ValidationResult> IValidator.ValidateAsync(object validatedObject, ValidationOptions options, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Object validatedObject
ValidationOptions options
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.Task<ValidationResult>

Implements

IValidator<TValidated>
IValidator
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX