Validation on server side using Fluent Validation

Validation is a necessary part of every application, we will have to validate the user inputs on client side as much as possible and then on server. When it comes to ASP.NET, it much easier to do the validation using FluentValidation.

Lets think about the POST, you will need to validate the null or empty strings – easy, I know. Below is your post model.

This is your validation object.

Now in your controller.

See how you check for the ModelState.IsValid, you must be thinking that do we need a another NuGet for this ? well this is the easy stuff. refer to documentation for more advance stuff, like below.


Leave a comment