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.

Allow multiple FluentValidationModelValidatorProvider.

See original GitHub issue

FluentValidation 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremySkinnercommented, Jan 29, 2021

Yes, that’s the right way to do it

0reactions
malylemire1commented, Jan 29, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

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