DataAnnotationValidateOptions<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 specific named options instance (or all when 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>
override this.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.
Implements
Remarks
The cancellationToken is propagated from Host.StartAsync(CancellationToken). By default, no startup timeout is applied. Configure HostOptions.StartupTimeout or pass a CancellationToken with a timeout to Host.StartAsync to bound I/O-bound async validators:
builder.Services.Configure<HostOptions>(opts =>
opts.StartupTimeout = TimeSpan.FromSeconds(30));