Skip to content

Issue with replacing IObjectModelValidator #30938

@amoorthaemer

Description

@amoorthaemer

Hi,

I followed your example on disabling validation (see: https://docs.microsoft.com/en-us/aspnet/core/mvc/models/validation?view=aspnetcore-5.0) and noticed some strange side-behavior, e.g. model validation on classes was indeed disabled, but validation on action (method) parameters (f.e. passed by query) resulted in a bad request (HTTP 400)

In short: a POST with a model in the body functioned as documented, but a GET with query parameters didn't.

the example code tested:

public class NullObjectModelValidator : IObjectModelValidator
{
    public void Validate(ActionContext actionContext,
        ValidationStateDictionary validationState, string prefix, object model)
    {

    }
}

... and ...

services.AddSingleton<IObjectModelValidator, NullObjectModelValidator>();

Is this by design or indeed a bug?

TIA

Bert

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsThis issue tracks updating documentationarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-model-binding

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions