Language

IAsyncValidatableObject.ValidateAsync Method

Definition

Determines whether the specified object is valid asynchronously, yielding validation results as each check completes.

public System.Collections.Generic.IAsyncEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> ValidateAsync(System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Threading.CancellationToken cancellationToken = default);
abstract member ValidateAsync : System.ComponentModel.DataAnnotations.ValidationContext * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<System.ComponentModel.DataAnnotations.ValidationResult>
Public Function ValidateAsync (validationContext As ValidationContext, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of ValidationResult)

Parameters

validationContext
ValidationContext

A ValidationContext instance that provides context about the validation operation, such as the object and member being validated.

cancellationToken
CancellationToken

The token to observe during asynchronous validation and enumeration of the validation results.

Returns

An IAsyncEnumerable<T> that yields ValidationResult instances as each validation check completes.

Remarks

This method must perform all applicable checks, including checks that can run synchronously.

The asynchronous Validator APIs do not automatically invoke Validate(ValidationContext) first. Share common checks through a helper when needed.

Applies to