Open petriashev opened 4 years ago
Is it possible to make this package work without registering FluentValidation in Startup.cs
?
Registering FluentValidation leads to following issues (correct me if it's wrong):
ValidateAsync
method on validator object.ValidationResult.Errors
(to me they are better than standard ASP.NET Core error response)@ChillerShock you are correct the built in MVC pipeline does everything synchronously therefore it is ultimately not a good choice for FluentValidation for anything but very rudimentary options.
The root of the issue is this library is dependent upon a IValidatorFactory instance which doesn't happen if you don't use the FluentValidation.AspNetCore package.
Just add the following line and you'll be good to go...
services.AddTransient<IValidatorFactory, HttpContextServiceProviderValidatorFactory>();
Edit: If you haven't already registered the HttpContextAccessor you need to do that as well
services.AddHttpContextAccessor();
@petriashev I agree on all fronts.... this package is too opinionated as currently constructed thought it is incredibly useful and valuable.
Started refactoring toward this issue
There are many requests to support other hosts (AzureFunctions) or other generators (NSwag). Package should be splitted to several parts.
Supposed parts:
Supposed packages: