Validator.ValidateValueAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Asynchronously throws a ValidationException if the given value is not valid for the ValidationAttributes.
public static System.Threading.Tasks.Task ValidateValueAsync(object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.IEnumerable<System.ComponentModel.DataAnnotations.ValidationAttribute> validationAttributes, System.Threading.CancellationToken cancellationToken = default);
static member ValidateValueAsync : obj * System.ComponentModel.DataAnnotations.ValidationContext * seq<System.ComponentModel.DataAnnotations.ValidationAttribute> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function ValidateValueAsync (value As Object, validationContext As ValidationContext, validationAttributes As IEnumerable(Of ValidationAttribute), Optional cancellationToken As CancellationToken = Nothing) As Task
Parameters
- value
- Object
The value to test.
- validationContext
- ValidationContext
Describes the object being tested.
- validationAttributes
- IEnumerable<ValidationAttribute>
The list of ValidationAttributes to validate this value against.
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A Task representing the asynchronous validation operation.
Exceptions
When validationContext is null.
When validationAttributes is null.
When value is found to be invalid.
The validation operation was canceled.