Skip to content

FluentValidation middleware doesn't work with [FromQuery] HTTP endpoint parameters #1743

@alex-voronin

Description

@alex-voronin

For example, we write an HTTP endpoint:

[WolverineGet("/welcome")]
public static async Task<IResult> HandleWelcome([FromQuery] WelcomeQuery query)
{
    ...
}

In this case, HttpChain will have the ComplexQueryStringType field set to the actual query type, while RequestType is still equal to typeof(void). As a result, the chain doesn’t pass the check in HttpChainFluentValidationPolicy:

foreach (var chain in chains.Where(x => x.HasRequestType))
{
    Apply(chain, container);
}

Therefore, no validation is applied to the endpoint.
For reference, all WolverineFx components are at version 4.12.2.

example.cs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions