Skip to content
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

Closed
dsolteszopyn opened this issue Nov 14, 2022 · 5 comments

Comments

@dsolteszopyn
Copy link

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:

  1. save a new user

Expected behavior
Validation should be successful if all rules are met.

@martin-arapovic-typeqast

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.

@dsolteszopyn
Copy link
Author

dsolteszopyn commented Nov 15, 2022 via email

@xts-velkumars
Copy link

@martin-arapovic-typeqast

Is this issue resolved ? I'm also facing same exception.

Do I need to downgrade to 10.4.0 from 11.2.2

@dsolteszopyn
Copy link
Author

you either need to downgrade or update your code based upon the PR mentioned above

@xts-velkumars
Copy link

Thank you @dsolteszopyn,

Its working as excepted after I changed my code.

Can we excepts async validators in futures release ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants