Skip to content

Add EditContext.IsValid(..) to determine if a field has any associated validation messages. #31252

Closed

Description

@pranavkm

Background and Motivation

Proposed API

Add an API to query if a FieldIdentifier is valid without having to get validation messages. We have several places that get the messages only to determine this condition e.g. https://github.com/dotnet/aspnetcore/blob/main/src/Components/Web/src/Forms/InputBase.cs#L245

This has the sneaky benefit of removing yet another Linq call because we do something more optimized to determine this condition.

Usage Examples

// some lines of code here
var isValid = EditContext.IsValid(FieldIdentifier);
if (!isValid)
{
   // Do stuff
}

Alternative Designs

Risks

Activity

  1. added
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    area-blazorIncludes: Blazor, Razor Components
    on Mar 25, 2021
  2. added
    enhancementThis issue represents an ask for new feature or an enhancement to an existing one
    on Mar 29, 2021
  3. deleted a comment from on Mar 29, 2021
  4. TanayParikh commented on Oct 19, 2021

    @TanayParikh
    Contributor

    @pranavkm is this something you envision for 7.0?

  5. added
    Priority:1Work that is critical for the release, but we could probably ship without
    on Oct 22, 2021
  6. 15 remaining items

  7. rasaconsulting-sandy commented on May 6, 2023

    @rasaconsulting-sandy

    This would be a great enhancement!

  8. modified the milestones: Backlog, 8.0-rc1 on Aug 14, 2023
  9. ghost locked as resolved and limited conversation to collaborators on Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:2Work that is important, but not critical for the releaseapi-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis 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 futurefeature-blazor-form-validationThis issue is related to forms validation in Blazorgood first issueGood for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issue

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions