EditContext.AddValidationTask 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.
Registers an async validation task for a specific field. The task is tracked for
pending/faulted state queries via IsValidationPending(FieldIdentifier)
and IsValidationFaulted(FieldIdentifier). If a task is already tracked
for this field, the previously registered CancellationTokenSource is cancelled
and the new task replaces it. The EditContext takes ownership of the supplied
cts: it will be cancelled if a subsequent validation supersedes this one,
and disposed once task completes.
public void AddValidationTask(in Microsoft.AspNetCore.Components.Forms.FieldIdentifier fieldIdentifier, System.Threading.Tasks.Task task, System.Threading.CancellationTokenSource cts);
member this.AddValidationTask : FieldIdentifier * System.Threading.Tasks.Task * System.Threading.CancellationTokenSource -> unit
Public Sub AddValidationTask (ByRef fieldIdentifier As FieldIdentifier, task As Task, cts As CancellationTokenSource)
Parameters
- fieldIdentifier
- FieldIdentifier
Identifies the field being validated.
- task
- Task
The async validation task to track.
The CancellationTokenSource that can cancel the task.
Remarks
If task is already completed, it is settled synchronously: the field is not parked in the pending state, a faulted task is surfaced via IsValidationFaulted(FieldIdentifier), and cts is disposed.
Validators backing task are expected to clear any prior validation messages for the field up-front (before awaiting), and to avoid writing partial results to a ValidationMessageStore on a path that may subsequently throw. If a validator does write partial state and then throws, those messages remain in the store until cleared by a subsequent successful validation.