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
add support for registering internal validator types through FluentValidationMvcConfiguration #1748
add support for registering internal validator types through FluentValidationMvcConfiguration #1748
Conversation
…lidationMvcConfiguration; add useful WithPropertyName method to PropertyChain
Hi, thanks for the suggestions. Please could you amend the PR to make the following changes:
If you could make those changes I'll get this merged in Thanks! |
Just to confirm, you are suggesting that |
Yes that seems like a reasonable approach. The existing |
That seems inconsistent with both Based on the documentation, it looks like the intent is for consumers of the library to call one of the |
Hm yes you're right, let's keep it consistent. Stick with using a single |
Done! |
Thanks! I'll try and get a patch release done later today that includes this. |
The documentation mentions being able to register
internal
validator types using the following syntax:... but this is incorrect. The pull request introducing the opt-in behavior modified the
IServiceCollection
extension methods and not any of theRegisterValidators...
methods defined byFluentValidationMvcConfiguration
. This PR adds a newIncludeInternalValidatorTypes
flag toFluentValidationMvcConfiguration
and that value will be passed to theIServiceCollection
extension method call made later (sinceFluentValidationMvcConfiguration
caches a collection of assemblies and all validators from all assemblies are registered at once).I also added a useful
WithPropertyName
method toPropertyChain
to allow for fluent declaration of property chains:validationContext.PropertyChain.WithPropertyName(validationContext.PropertyName).WithPropertyName("OtherProperty")