Skip to content

Model validation of Dictionary<string, string> having null values for some key passes #21501

@levroz

Description

@levroz

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.
public class Dto
{
	public IDictionary<string, string> Map { get; set; }
}
{ 
    "Map": { 
        "ok": "ok",
        "oktoo": "5",
        "notok": null
    }
}

Further technical details

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewThis issue impacts only small number of customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-model-bindingseverity-majorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions