question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

This library will not work if you use DI in your AbstractValidators.

See original GitHub issue

I have nearly identical code to the issue here: https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/issues/14

My validators have lots of DI going on, and I get a slew of errors out to my console when the app starts.

DevConf [10:18:27 Warning] MicroElements.Swashbuckle.FluentValidation.FluentValidationRules
GetValidator for type 'System.Collections.Generic.List`1[MyApp.API.ViewModels.ServiceUpdateViewModel]' fails.
System.InvalidOperationException: Cannot resolve 'FluentValidation.IValidator`1[System.Collections.Generic.List`1[MyApp.API.ViewModels.ServiceUpdateViewModel]]' from root provider because it requires scoped service 'MyApp.API.Validations.ServiceUpdateViewModelValidator'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, IServiceScope scope, IServiceScope rootScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at FluentValidation.AspNetCore.ServiceProviderValidatorFactory.CreateInstance(Type validatorType) in C:\Projects\FluentValidation\src\FluentValidation.AspNetCore\ServiceProviderValidatorFactory.cs:line 32
   at MicroElements.Swashbuckle.FluentValidation.FluentValidationRules.Apply(Schema schema, SchemaFilterContext context) in /home/travis/build/micro-elements/MicroElements.Swashbuckle.FluentValidation/src/MicroElements.Swashbuckle.FluentValidation/FluentValidationRules.cs:line 92

We need a better way to access the validators.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:40 (21 by maintainers)

github_iconTop GitHub Comments

1reaction
VictorioBerracommented, Aug 28, 2018

Trying to reproduce and upload a sample for you. Not going so well so far.

0reactions
petriashevcommented, Nov 12, 2018

add new issues for problems in new version. Old version locked to Swashbuckle < 4.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dependency Injection — FluentValidation documentation
Validators can be used with any dependency injection library, such as Microsoft.Extensions.DependencyInjection . To inject a validator for a specific model, ...
Read more >
c# - .NET Core - FluentValidation inject
I am creating ASP.NET CORE (2.1) project and trying to use FluentValidation library (https://fluentvalidation.net/). Unfortunately I am getting ...
Read more >
Using FluentValidation.DependencyInjectionExtensions To ...
This article discusses the use of FluentValidation.DependencyInjectionExtensions, an extension for the popular .NET validation library ...
Read more >
Using Fluent Validation in ASP.NET Core
This is how you implement manual validation with Fluent Validation Library in ASP.NET Core Applications. You could have your own variants of course....
Read more >
Adding validation to strongly typed configuration objects ...
In this post I describe how to to verify your strongly typed configuration objects are correctly bound to your config at start up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found