Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Validation incorrect for dynamic collections when using TryUpdateModelAsync() #2941

@dougbu

Description

@dougbu

The problem described in #2294 has been fixed for controller properties and action parameters. Unfortunately that problem remains when using TryUpdateModelAsync(). The following form data (an example from #2294) will not be correctly validated because the IObjectModelValidator will not be informed that model nodes collection[key1] or collection[key2] exist.

Collection.index = key1,key2
Collection[key1].Name = name1
Collection[key2].Name = name2

Root cause: ModelBindingHelper.TryUpdateModelAsync() completely ignores the ModelValidationNode tree the model binding system returns, passing a new ModelValidationNode instance to the IObjectModelValidator. This method does not even check ModelBindingResult.IsModelSet before using ...Model.

(noticed while investigating #2633)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions