-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Automatic FluentValidation and Custom Validator #720
Comments
It happened to me when I updated the FluentValidation nuget package and look for solution on google. I found none, so I decided to downgrade the FluentValidation version. |
FluentValidation.DependencyInjectionExtensions -> 11.5.1 This issue no longer exists. Tested this on the dotnet-7 branch with the latest FV packages. |
I found the solution. I found this code on github https://github.com/salt-repositories/din-api/blob/97edd4b02a173dc6881cc19b12447c6154a94b98/src/Din.Domain.Middlewares/Mediatr/FluentValidationMiddleware.cs#L30 update to the latest FluentValidation packages: public class ValidationBehavior<TRequest, TResponse>(IEnumerable<IValidator> validators)
} |
Describe the bug
When I try to add an entity, it causes an error related to automatic validation
{
"messages": [
"Validator "CreateBrandRequestValidator" can't be used with ASP.NET automatic validation as it contains asynchronous rules. ASP.NET's validation pipeline is not asynchronous and can't invoke asynchronous rules. Remove the asynchronous rules in order for this validator to run."
],
"source": "FluentValidation.AbstractValidator`1",
"exception": "Validator "CreateBrandRequestValidator" can't be used with ASP.NET automatic validation as it contains asynchronous rules. ASP.NET's validation pipeline is not asynchronous and can't invoke asynchronous rules. Remove the asynchronous rules in order for this validator to run.",
"errorId": "d5d95cd8-69a2-499e-a26f-71451765ab57",
"supportMessage": "Provide the ErrorId to the support team for further analysis.",
"statusCode": 500
}
To Reproduce
Steps to reproduce the behavior:
Post to URL: {{url}}/v1/brands
Payload:
{
"name":"Bra1nod #29",
"description":"Something Cool!"
}
Error appears.
Remarks:
This issue is related to FluentValidation.AspNetCore and FluentValidation.DependencyInjectionExtensions, which was bumped to v11.1.0 in my machine, back to v10.4.0 works normally.
The text was updated successfully, but these errors were encountered: