Class AsyncValidator<T>
Supports fluent registration of synchronous and asynchronous validation rules.
Inheritance
AsyncValidator<T>
Assembly: ValidationFramework.dll
Syntax
public class AsyncValidator<T> : IValidator<T>, IAsyncValidator<T>
Type Parameters
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
Returns
|
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
Returns
|
Edit this page
View Source
AddRule(Func<T, bool>, string)
Declaration
public AsyncValidator<T> AddRule(Func<T, bool> rule, string errorMessage)
Parameters
Returns
|
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
|
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
|
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
Returns
Implements