Open Tragetaschen opened 2 years ago
@Tragetaschen I had a similar requirement,
https://github.com/dotnet/aspnetcore/issues/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.
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.
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.
Is there an existing issue for this?
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 theValidationMessage
, 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 entireValidationSummary
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-L18To 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