IAsyncValidatableObject Interface
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.
Provides a way for an object to be validated asynchronously.
public interface class IAsyncValidatableObject : System::ComponentModel::DataAnnotations::IValidatableObject
public interface IAsyncValidatableObject : System.ComponentModel.DataAnnotations.IValidatableObject
type IAsyncValidatableObject = interface
interface IValidatableObject
Public Interface IAsyncValidatableObject
Implements IValidatableObject
- Implements
Remarks
When an object implements IAsyncValidatableObject, the asynchronous Validator APIs (such as TryValidateObjectAsync(Object, ValidationContext, ICollection<ValidationResult>, CancellationToken)) invoke only ValidateAsync(ValidationContext, CancellationToken); Validate(ValidationContext) is not called on the async path. The synchronous Validator APIs continue to invoke Validate(ValidationContext).
Provide a synchronous implementation of Validate(ValidationContext) when it can evaluate the applicable rules, returning validation errors for rules that reject the object. If a required rule applies but cannot be evaluated synchronously, throw InvalidOperationException with a message directing callers to an asynchronous validation entry point.
Returning no validation errors without evaluating a rule is appropriate only when the rule does not apply. Do not return an empty result merely because a required asynchronous check applies but cannot run synchronously. An empty result does not indicate pending validation or arrange a later asynchronous invocation.
Do not implement Validate(ValidationContext) by blocking on asynchronous work or asynchronously enumerated results.
Methods
| Name | Description |
|---|---|
| Validate(ValidationContext) |
Determines whether the specified object is valid. (Inherited from IValidatableObject) |
| ValidateAsync(ValidationContext, CancellationToken) |
Determines whether the specified object is valid asynchronously, yielding validation results as each check completes. |