Closed falconmick closed 2 years ago
@falconmick No. this will not help. This is because you have a default input validator Validators
, which calls sp.GetServices()
(returning empty array)
Same thing is happening with Validator
, but it is using GetRequiredService
I am ok to align this behavior and throw if no validators registered
Yeah I think throwing of no validation found is just a win win, would suck if bad data got into your system because you accidentally nuked a part of your dependency injection
Anyway you should cover all system critical parts with tests 😉
Describe the bug If I define an argument as having UseFluentValidation I would expect an error if no valid agora found
To Reproduce Add UseFluentValidation to a field which has no validator
Expected behavior An error back from my request letting me know that a validator is missing
Additional context Looking at the source leads me to believe that potentially the solution would be to middlewareContext.ReportError() when we get to line 43 of ValidationMiddleware if InputValidators has a length of 0, however I'm not sure I know enough about the library to tell if this is the correct way to ensure that the validator exists.
For now I am manually wiring up the validator