-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Can't use async in request validators with latest version of FluentValidations #799
Comments
Hi @dsolteszopyn , You've probably updated to FluentValidation version 11.x, where they throwing exceptions if validation is integrated with ASP.NET. Check docs You need to use FluentValidation version 10.x, for it to work with Async methods. If this PR gets merged, using Async methods will work, because Validation will be triggered by MediatR... For now try to use FluentValidation version 10, or move validation to a MediatR's pipeline behavior as shown in mentioned PR. |
I updated my code to use the new pattern, works as expected now :)
…________________________________
From: Martin Arapović ***@***.***>
Sent: Tuesday, November 15, 2022 10:35:42 AM
To: fullstackhero/dotnet-webapi-boilerplate ***@***.***>
Cc: Soltesz, Danny ***@***.***>; Mention ***@***.***>
Subject: Re: [fullstackhero/dotnet-webapi-boilerplate] Can't use async in request validators with latest version of FluentValidations (Issue #799)
[CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe]
Hi @dsolteszopyn<https://protect-us.mimecast.com/s/lmjbCG62OqtqAnBfQ4fZD?domain=github.com> ,
You've probably updated to FluentValidation version 11.x, where they throwing exceptions if validation is integrated with ASP.NET. Check docs<https://protect-us.mimecast.com/s/B3syCBB2J0fA8qDtzoy-n?domain=docs.fluentvalidation.net>
You need to use FluentValidation version 10.x, for it to work with Async methods.
If this PR<https://protect-us.mimecast.com/s/U5oyCDk2LnTM3poi59vzr?domain=github.com> gets merged, using Async methods will work, because Validation will be triggered by MediatR...
For now try to use FluentValidation version 10, or move validation to a MediatR's pipeline behavior as shown in mentioned PR<https://protect-us.mimecast.com/s/U5oyCDk2LnTM3poi59vzr?domain=github.com>.
—
Reply to this email directly, view it on GitHub<https://protect-us.mimecast.com/s/3tSJCER2Motnpylip_-0_?domain=github.com>, or unsubscribe<https://protect-us.mimecast.com/s/YDTyCJ62gwtyKOBHva4l4?domain=github.com>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Is this issue resolved ? I'm also facing same exception. Do I need to downgrade to 10.4.0 from 11.2.2 |
you either need to downgrade or update your code based upon the PR mentioned above |
Thank you @dsolteszopyn, Its working as excepted after I changed my code. Can we excepts async validators in futures release ? |
Validator "CreateUserRequestValidator" 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.
Steps to reproduce the behavior:
Expected behavior
Validation should be successful if all rules are met.
The text was updated successfully, but these errors were encountered: