Skip to content
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

Blazor: Model-specific validation errors of a list of child models cannot be shown individually #42575

Open
1 task done
Tragetaschen opened this issue Jul 5, 2022 · 3 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-builtin-components Features related to the built in components we ship or could ship in the future
Milestone

Comments

@Tragetaschen
Copy link
Contributor

Tragetaschen commented Jul 5, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a parent model with a list of child models in an EditForm/ObjectGraphDataAnnotationsValidator/ValidateComplexType context. I iterate over the child models and show form UI for each individual list item and want to show item-specific validation errors. For individual properties, I can show the ValidationMessage, but I cannot find a way to show validation errors for the item itself.

Expected Behavior

I want a method to show child-model specific errors that are not bound to individual properties

Steps To Reproduce

I have extracted a repository containing code that shows the issue: https://github.com/Tragetaschen/blazor-nested-list-validation

There is a parent model containing a list of child models (with some validation rules)
https://github.com/Tragetaschen/blazor-nested-list-validation/blob/main/Pages/ParentModel.cs#L7-L10

The child model has a couple of properties and an IValidatableObject implementation:
https://github.com/Tragetaschen/blazor-nested-list-validation/blob/main/Pages/ChildModel.cs#L13-L19
Note that this does not reference individual fields in the validation result.

In the EditForm, I can reference the entire ValidationSummary that shows all errors including those for the child model, I can reference the errors for individual properties of the child model, but I cannot get errors on the child model level.
https://github.com/Tragetaschen/blazor-nested-list-validation/blob/main/Pages/Form.razor#L15-L18

To reproduce, "Add" a child model, fill the Req field and then "Submit" leaving the Name and Alt fields empty. You will see the child model error in the validation summary, but not at the individual item level.

Exceptions (if any)

No response

.NET Version

6.0.400-preview.22301.10

Anything else?

No response

@javiercn javiercn added area-blazor Includes: Blazor, Razor Components feature-blazor-builtin-components Features related to the built in components we ship or could ship in the future labels Jul 5, 2022
@MariovanZeist
Copy link
Contributor

@Tragetaschen I had a similar requirement,
#40306
I ended up with a system where each child was surrounded by an EditForm, and aggregated all errors in my main component. to show if there was an error in any of the subitems.

@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Jul 5, 2022
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Jul 5, 2022
@ghost
Copy link

ghost commented Jul 5, 2022

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 mkArtakMSFT modified the milestones: Backlog, BlazorPlanning Nov 5, 2023
@mkArtakMSFT mkArtakMSFT modified the milestones: Planning: WebUI, Backlog Dec 3, 2023
@ghost
Copy link

ghost commented Dec 3, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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-builtin-components Features related to the built in components we ship or could ship in the future
Projects
None yet
Development

No branches or pull requests

4 participants