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.

How to use FluentValidation with Web Api 2.0?

See original GitHub issue

I am trying to use Fluent Validation in a web api 2 project but I can’t get the Model State to work. I downloaded FluentValidation.WebAPI 5.6.2 and added this line to my Application_Start

  FluentValidationModelValidatorProvider.Configure(GlobalConfiguration.Configuration);

Then in my model I added

[Validator(typeof(LotValidator))]

yet my ModelState.IsValid is always valid. I don’t know what I am missing or if it the fact that I have my model in a different class project(though I do reference FluentValidation 5.6.2) in the project that contains my models.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
akamudcommented, Nov 13, 2015

@chobo2 as stated above by @JeremySkinner, the code is very trivial, you should just copy this class into your project.

1reaction
chobo2commented, Nov 9, 2015

I made a simple webapi project. Still getting this error maybe you can see what I did wrong.

http://1drv.ms/1Nn5qdZ

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET WebApi 2 — FluentValidation documentation
Integration with ASP.NET WebApi 2 is no longer supported as of FluentValidation 9. Please migrate to ASP.NET Core. FluentValidation 8.x provided integration ...
Read more >
How to use FluentValidation with Web Api 2.0?
I am trying to use Fluent Validation in a web api 2 project but I can't get the Model State to work. I...
Read more >
How to Use FluentValidation in ASP.NET Core
Learn how to make use of FluentValidation in an ASP.NET Core application, to validate user input and make our applications easier to maintain...
Read more >
FluentValidation in ASP.NET WebAPI | by Adam Connelly
Out of the box, WebAPI allows you to validate your objects using the standard MVC method of decorating your classes with attributes: I've...
Read more >
Using FluentValidation in ASP.NET Web API for Model ...
aspdotnetcore #dotnet6 # fluentvalidation API Model validation using FluentValidation NuGet package in ASP.NET 6 (.
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