IAsyncValidateOptions<TOptions>.ValidateAsync 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 validates a specified named options instance (or all if name is null).
public System.Threading.Tasks.Task<Microsoft.Extensions.Options.ValidateOptionsResult> ValidateAsync(string? name, TOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member ValidateAsync : string * 'Options * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.Options.ValidateOptionsResult>
Public Function ValidateAsync (name As String, options As TOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ValidateOptionsResult)
Parameters
- name
- String
The name of the options instance being validated.
- options
- TOptions
The options instance.
- cancellationToken
- CancellationToken
The token to monitor for cancellation requests.
Returns
The ValidateOptionsResult result.
Remarks
This method must perform all applicable checks for this validator, including checks that can complete synchronously. The built-in asynchronous options creation path invokes this method instead of invoking Validate(String, TOptions) on the same validator. Share common checks through a helper when needed. Synchronous options creation invokes the inherited Validate(String, TOptions) method. Implement that method with equivalent synchronous validation when possible. If a required rule applies but cannot be evaluated synchronously, return a failed ValidateOptionsResult indicating that synchronous validation is unsupported; do not return Success.