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 occurs against declared type rather than real type #7952

Closed
@Materix

Description

@Materix

Is this a Bug or Feature request?:

Bug - Probably regression

Steps to reproduce (preferably a link to a GitHub repo with a repro project):

Repo with example project on: https://github.com/Materix/ValidationInterface

Send POST request on api/fruit with {"type":"orange"} as body and Content-Type: application/json

Expected result: ModelState.IsValid = false
Result: ModelState.IsValid = true

CompatibilityVersion is set to Version_2_1.
Without setting all works correctly
On 2.0.0. all works correctly.

Description of the problem:

I have interface of model class (IFruit) from which two class derived (Apple, Orange). I have custom JsonConventer which determine proper type bases on one value from json. All validation attributes were in individual implementation. When I bind to IFruit ModelState.IsValid always returns true.

Version of Microsoft.AspNetCore.Mvc or Microsoft.AspNetCore.App or Microsoft.AspNetCore.Mvc: 2.1.1

Images:

obraz
obraz
obraz

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions