Allow multiple FluentValidationModelValidatorProvider.
See original GitHub issueFluentValidation 9.4.0
Asp.Net Core 5
The constructor of FluentValidationObjectModelValidator prevent adding another derived class of type FluentValidationModelValidatorProvider. I want to add another FluentValidationModelValidatorProvider that does not replace the behavior of the default one.
public FluentValidationObjectModelValidator( IModelMetadataProvider modelMetadataProvider, IList<IModelValidatorProvider> validatorProviders, bool runMvcValidation) : base(modelMetadataProvider, validatorProviders) { _runMvcValidation = runMvcValidation; _fvProvider = validatorProviders.SingleOrDefault(x => x is FluentValidationModelValidatorProvider) as FluentValidationModelValidatorProvider; }
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to hook FluentValidator to a Web API?
I ended up using something else FluentValidation.Mvc.FluentValidationModelValidatorProvider.Configure and then FluentValidation.WebApi.
Read more >ASP.NET Core — FluentValidation documentation
FluentValidation can be used within ASP.NET Core web applications to validate incoming models. There are two main approaches for doing this: Manual validation ......
Read more >Parent Validation not being called when child ...
I removed the "top-level" validator constructor dependency. This allowed me to just simply call: FluentValidationModelValidatorProvider.
Read more >Custom Validation in ASP.NET Web API with ...
This architecture allows us to do the validation on the Web API side of the app, and automatically include all validation errors in...
Read more >Fluent Validation in ASP.NET MVC
Step 6: – Create the controller First, create the controller and two action methods for view and insert the value in it.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, that’s the right way to do it
Thanks I think I can replace it and only add another FluentValidationModelValidator with this :
public override void CreateValidators(ModelValidatorProviderContext context) { base.CreateValidators(context); context.Results.Add(new ValidatorItem { IsReusable = false, Validator = new CoreModelValidator(_implicitValidationEnabled) }); } }
base.CreateValidators(context); will create the default FluentValidationModelValidator and then I can add my custom one.