Skip to content

[Blazor] "ValidateComplexType" does not work for dictionaries #44143

@ageiter

Description

@ageiter

Is there an existing issue for this?

  • I have searched the existing issues

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....

// Here the validation doesn't work
[ValidateComplexType]
public IDictionary<Guid, PersonUpdateDto> EditingPersons { get; set; }

// Here the validation works
[ValidateComplexType]
public IList<PersonUpdateDto> EditingPersons2 { get; set; }

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing one

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions