I am trying to use fluentvalidation in my WebAPI projects for an asynchronous rules validations (e.g. check username duplication). (respecting the avoidance of manual use inside controllers, I want to validating before accessing the controller)
The documentation provided by the library saying that: You should not use asynchronous rules when using automatic validation with ASP.NET as ASP.NET’s validation pipeline is not asynchronous. If you use asynchronous rules with ASP.NET’s automatic validation, they will always be run synchronously.
I know it is possible to use manually the validation from the controller. However, I feel it breaks the clean architecture and coding convention in my App. I am trying to keep controllers free from any type of validation and I found it easy when validation does not necessitate database access. However, the need for rules validation Asynchronously will change the situation.
To Sum up:
I need to validate some rules asynchronously for some BM(s)
Documentary advise to use it manually and avoid using auto validation pipeline
I don't want to validateAsync inside the controller
Do you think the utilization of interceptor will make a sense?