Skip to content

Blazor form Validation should have IsValid() method #35260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PersyJack opened this issue Aug 11, 2021 · 4 comments
Closed

Blazor form Validation should have IsValid() method #35260

PersyJack opened this issue Aug 11, 2021 · 4 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-form-validation This issue is related to forms validation in Blazor
Milestone

Comments

@PersyJack
Copy link

Currently a form can be validated with editContext.Validate() but that's not always the desired way to know if the form is valid. For example, according to docs [https://docs.microsoft.com/en-us/aspnet/core/blazor/forms-validation?view=aspnetcore-5.0#enable-the-submit-button-based-on-form-validation-1], enabling submit button upon field change has this side effect:

A side effect of the preceding approach is that a validation summary (ValidationSummary component) is populated with invalid fields after the user interacts with any one field.

The ValidationMessages errors appear even if the inputs are NOT marked modified (if they are required but untouched, which is correct during full validation)

The document suggest hiding ValidationSummary with a parameter but if the user is using ValidationMessages, then all inputs errors are triggered. MessageStore.Clear() does not clear these errors because it doesn't interact with fieldstate of editcontext.

If the user just wants to know if the form is valid at a given time (i.e. OnFieldChange) there should be a method returning a bool without actually triggering errors. EditContext has GetValidationMessages method but that's based on previous validation request.

If we can have an IsValid method or change MessageStore.Clear method to clear EditContext fieldstates then this can be archived.

@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components feature-blazor-form-validation This issue is related to forms validation in Blazor enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Aug 11, 2021
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Aug 11, 2021
@ghost
Copy link

ghost commented Aug 11, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@mkArtakMSFT
Copy link
Contributor

Thanks for contacting us.
If you're requesting a specific API, please file a new issue based on the API Proposal template, as that has many details that we need.

@mkArtakMSFT
Copy link
Contributor

If you do so, please close this issue. Otherwise, we'll look at this in the future, after getting more customer feedback.

@PersyJack
Copy link
Author

I'm closing this as this is already requested with #31252

@ghost ghost locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-form-validation This issue is related to forms validation in Blazor
Projects
None yet
Development

No branches or pull requests

2 participants