Open ageiter opened 2 years ago
Thanks for contacting us.
We're moving this issue to the .NET 8 Planning
milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
The reason this is happening is because ObjectGraphDataAnnotationsValidator
handles properties with types implementing IEnumerable<T>
by recursively validating each T
instance. Since the T
in the context of an IDictionary<TKey, TValue>
is just a KeyValuePair<TKey, TValue>
, the underlying TValue
instances don't get validated. Labeling this as an enhancement since the behavior being described is by design. This feature is something we may consider when handing https://github.com/dotnet/aspnetcore/issues/28640.
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 use an EditForm with the "ObjectGraphDataAnnotationsValidator". In my model I have several lists with the annotation "ValidateComplexType". For the collections with IList it works. But for the dictionary the validation does not work.
As a test I have created a list and a dictionary which contain the same objects. I then set a property in PersonUpdateDto to null. When I do this on the list, the validation fails ( that is correct). If I do this on the object in the dictionary, then the validator does not detect this....
Expected Behavior
Input errors are also detected for objects in dictionaries and a validation error occurs. Exactly how this works with IList.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
6.0.400
Anything else?
Microsoft.AspNetCore.Components.DataAnnotations.Validation: 3.2.0-rc1.20223.4