Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Blazor form async validation enhancements #7680

Copy link
Copy link

Description

@SteveSandersonMS
Issue body actions

Follows on from #7614

Design ideas:

 * - Add method: editContext.AddValidationTask(FieldIdentifier f, Task t)
 *   It adds the task to a HashSet<Task> on both the FieldState and the EditContext,
 *   so we can easily get all the tasks for a given field and across the whole EditContext
 *   Also it awaits the task completion, and then regardless of outcome (success/fail/cancel),
 *   it removes the task from those hashsets.
 * - Add method: editContext.WhenAllValidationTasks()
 *   Add method: editContext.WhenAllValidationTasks(FieldIdentifier f)
 *   These return Task.WhenAll(hashSet.Values), or Task.Completed if there are none
 * - Optionally also add editContext.HasPendingValidationTasks()
 * - Add method: editContext.ValidateAsync() that awaits all the validation tasks then
 *   returns true if there are no validation messages, false otherwise
 * - Now a validation library can register tasks whenever it starts an async validation process,
 *   can cancel them if it wants, and can still issue ValidationResultsChanged notifications when
 *   each task completes. So a UI can determine whether to show "pending" state on a per-field
 *   and per-form basis, and will re-render as each field's results arrive.
 * - Note: it's unclear why we'd need WhenAllValidationTasks(FieldIdentifier) (i.e., per-field),
 *   since you wouldn't "await" this to get per-field updates (rather, you'd use ValidationResultsChanged).
 *   Maybe WhenAllValidationTasks can be private, and only called by ValidateAsync. We just expose
 *   public HasPendingValidationTasks (per-field and per-edit-context).

Will implement this shortly after getting more of the system in place, assuming it still appears to be the correct design.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Pillar: Complete Blazor Webaffected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-builtin-componentsFeatures related to the built in components we ship or could ship in the futureFeatures related to the built in components we ship or could ship in the futurefeature-blazor-form-validationThis issue is related to forms validation in BlazorThis issue is related to forms validation in Blazoron-roadmapListed on the current release roadmapListed on the current release roadmapseverity-minorThis label is used by an internal toolThis label is used by an internal tool

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

Morty Proxy This is a proxified and sanitized view of the page, visit original site.