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.

Run ASP.NET Core default validation first

See original GitHub issue

System Details

  • FluentValidation version: 8.0.100
  • Web Framework version (eg ASP.NET Core 2.1, MVC 5, WebApi 2. Delete if not applicable): ASP.NET Core 2.1

Issue Description

What I am looking for is basically exact opposite of :

.AddFluentValidation(fv =>
                {
                    fv.RunDefaultMvcValidationAfterFluentValidationExecutes = true;
                })

Basically, trying to run the default data annotation validations before fluent validation validators

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
JeremySkinnercommented, Oct 24, 2018

DataAnnotations tends to mess with FluentValidation if it runs first, as if DataAnnotations encounters a validation failure then it will not allow FV to add any errors for the same property (or this certainly used to be the case). This is usually undesirable, which is why FV should typically run first. I don’t really feel there’s a need to make it configurable as it’s easy enough to swap them around in an AddMvcOptions call if you really want to do it.

1reaction
JeremySkinnercommented, Oct 22, 2018

The ModelValidatorProviders collection is part of MVC - take a look at the AddMvcOptions method that allows you to customise the MVC bootstrapping process:

.AddFluentValidation(...).AddMvcOptions(options => {
	// access options.ModelValidatorProviders here, reorder as necessary 
});
				
Read more comments on GitHub >

github_iconTop Results From Across the Web

Model validation in ASP.NET Core MVC and Razor Pages
Model validation occurs after model binding and reports errors where data doesn't conform to business rules. For example, a 0 is entered in...
Read more >
ASP.NET Core MVC Model Validation
In Asp.Net Core, Model state always return validation errors in a normal HTML format in the interface. This will continue the validation process ......
Read more >
Validation of ASP.NET Core options during startup
There are easy way to validating with using IStartupFilter and IValidateOptions . You can just put below code your ASP.NET Core project. And ......
Read more >
Model Validation in ASP.NET Core [Beginner to Expert]
Model Validation is a technique to provide rules for model properties and validating these rules so that they are not broken. When rules...
Read more >
How to Use ModelState Validation in ASP.NET Core Web API
In this article, we are going to talk how to use ModelState validation. Also we are going to see manual and automatic validation....
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