EditContext.ValidateAsync(CancellationToken) 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.
Validates this EditContext asynchronously, awaiting any validation tasks that handlers register via AddAsyncValidator(Func<CancellationToken,Task>).
public System.Threading.Tasks.Task<bool> ValidateAsync(System.Threading.CancellationToken cancellationToken = default);
member this.ValidateAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>
Public Function ValidateAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)
Parameters
- cancellationToken
- CancellationToken
Cancels this validation pass; it is passed to each registered validator. If cancelled (including already-cancelled on entry) this method throws OperationCanceledException once the registered tasks settle, and the previous faulted state is preserved.
Returns
true if there are no validation messages and no registered task faulted; otherwise false.
Exceptions
cancellationToken was cancelled.
Remarks
Pending field-level validations are superseded. While tasks are in flight the parameterless IsValidationPending() is true. A non-cancellation exception on a registered task is contained (the form is marked faulted via IsValidationFaulted() and the method returns false) but not surfaced. A validator that throws synchronously or returns a null task is a programming bug and propagates to the caller. Do not call validation re-entrantly from a handler.