How to use FluentValidation with Web Api 2.0?
See original GitHub issueI 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:
- Created 8 years ago
- Comments:7 (4 by maintainers)
Top 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 >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
@chobo2 as stated above by @JeremySkinner, the code is very trivial, you should just copy this class into your project.
I made a simple webapi project. Still getting this error maybe you can see what I did wrong.
http://1drv.ms/1Nn5qdZ