Validation Framework
Search Results for

    Show / Hide Table of Contents

    Class AsyncValidator<T>

    Supports fluent registration of synchronous and asynchronous validation rules.

    Inheritance
    object
    AsyncValidator<T>
    Implements
    IValidator<T>
    IAsyncValidator<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: ValidationFramework
    Assembly: ValidationFramework.dll
    Syntax
    public class AsyncValidator<T> : IValidator<T>, IAsyncValidator<T>
    Type Parameters
    Name Description
    T

    Constructors

    | Edit this page View Source

    AsyncValidator(string?)

    Creates a validator with an optional field name for error reporting.

    Declaration
    public AsyncValidator(string? fieldName = null)
    Parameters
    Type Name Description
    string fieldName

    Methods

    | Edit this page View Source

    AddAsyncRule(Func<T, CancellationToken, Task<bool>>, string)

    Adds an asynchronous rule that receives the caller's cancellation token.

    Declaration
    public AsyncValidator<T> AddAsyncRule(Func<T, CancellationToken, Task<bool>> rule, string errorMessage)
    Parameters
    Type Name Description
    Func<T, CancellationToken, Task<bool>> rule
    string errorMessage
    Returns
    Type Description
    AsyncValidator<T>
    | Edit this page View Source

    AddAsyncRule(Func<T, Task<bool>>, string)

    Adds an asynchronous rule.

    Declaration
    public AsyncValidator<T> AddAsyncRule(Func<T, Task<bool>> rule, string errorMessage)
    Parameters
    Type Name Description
    Func<T, Task<bool>> rule
    string errorMessage
    Returns
    Type Description
    AsyncValidator<T>
    | Edit this page View Source

    AddRule(Func<T, bool>, string)

    Adds a synchronous rule.

    Declaration
    public AsyncValidator<T> AddRule(Func<T, bool> rule, string errorMessage)
    Parameters
    Type Name Description
    Func<T, bool> rule
    string errorMessage
    Returns
    Type Description
    AsyncValidator<T>
    | Edit this page View Source

    Validate(T)

    Runs synchronous rules only. Use ValidateAsync for full validation, including every asynchronous rule.

    Declaration
    public ValidationResult Validate(T value)
    Parameters
    Type Name Description
    T value
    Returns
    Type Description
    ValidationResult
    | Edit this page View Source

    ValidateAsync(T)

    Runs synchronous rules followed by asynchronous rules.

    Declaration
    public Task<ValidationResult> ValidateAsync(T value)
    Parameters
    Type Name Description
    T value
    Returns
    Type Description
    Task<ValidationResult>
    | Edit this page View Source

    ValidateAsync(T, CancellationToken)

    Runs all rules sequentially using a snapshot of registrations for this invocation. Cancellation and rule exceptions propagate to the caller.

    Declaration
    public Task<ValidationResult> ValidateAsync(T value, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    T value
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<ValidationResult>

    Implements

    IValidator<T>
    IAsyncValidator<T>
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX