Language

Validator.ValidatePropertyAsync Method

Definition

Asynchronously throws a ValidationException if the given property value is not valid.

[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
public static System.Threading.Tasks.Task ValidatePropertyAsync(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Threading.CancellationToken cancellationToken = default);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")>]
static member ValidatePropertyAsync : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function ValidatePropertyAsync (value As Object, validationContext As ValidationContext, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

value
Object

The value to test.

validationContext
ValidationContext

Describes the object being validated and provides services and context for the validators.

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

A Task representing the asynchronous validation operation.

Attributes

Exceptions

validationContext is null, or MemberName is null or empty.

MemberName does not identify a valid public, non-indexer property, or value cannot be assigned to that property.

When value is invalid for this property.

The validation operation was canceled.

Applies to