Model validation of Dictionary<string, string> having null values for some key passes
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Describe the bug
**background:** nullable annotation context is enabled at project level
**Actual behavior:** A string-to-string dictionary with null-values for some keys passes model validation
**Expected behavior:** it should fail the model validation
### To Reproduce
1. Define an API-controller action that takes the below DTO as an argument
2. Pass the below JSON to is using PostMan or a similar tool.
``` C#
public class Dto
{
public IDictionary Map { get; set; }
}
```
``` JSON
{
"Map": {
"ok": "ok",
"oktoo": "5",
"notok": null
}
}
```
### Further technical details
- .NET Core 3.1
- Maybe related to https://github.com/dotnet/aspnetcore/issues/13512
- See DictionaryModelBinderIntegrationTest.DictionaryModelBinder_DictionaryOfSimpleType_NullValue_DoesNotResultInRequiredValidation() - it validates the current behavior, which seems to me to be wrong, if nullable annotation context is enabled
Contributor guide
Assessment
This issue has not been assessed yet.