Skip to content

Configure to work with manual validation #112

@wonea

Description

@wonea

Hi, I'm currently moving an API from FluentValidation 10 to 11, removing automatic validation and doing manual validation via an IAsyncActionFilter. This is because there is quite a lot of async validation throughout the API.

The IAsyncActionFilter is working well however MicroElements.Swashbuckle.FluentValidation is no longer decorating the Swagger pages with validation. How can I configure MicroElements.Swashbuckle.FluentValidation to work with the service provider.

https://docs.fluentvalidation.net/en/latest/aspnet.html
FluentValidation/FluentValidation#1961

Add validators to the service collection

services.AddValidatorsFromAssemblies(typeof(MyClass).Assembly);

I can get the annotations working using the following line, however now I get deprecation warnings in my code

services.TryAddTransient<IValidatorFactory, ServiceProviderValidatorFactory>();

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