Posts

Showing posts with the label validation

Integrating Custom Validation with ASP.NET MVC ModelState

Image
One common pattern we see in ASP.NET MVC controller actions is a conditional check for ModelState.IsValid , with different branches getting executed based on whether the result is true or false . The ModelState captures errors arising from data annotations such as Required and StringLength . When there are custom validations that cannot be captured using data annotations, what usually happens is that these validations are checked in the success block of ModelState.IsValid . In this post we are going to talk about how to integrate custom validation into ModelState .

Custom Validator in Fluent Validation

Image
Fluent validation is an excellent validation framework for and written in .NET. It is easy to use and supports the most common validation scenarios out of the box; I highly recommend that you use it in your projects. There are times, however, that you want to add your own validators in order to support your business rules. In this post, we will be implementing a custom generic validator with arguments.

Validation in Entity Framework Code First

Image
Entity framework code first has support for validation for frequent validation scenarios. In this post, we will look at a couple of ways on how this can be achieved. If you are new to Entity framework code first, you might want to check out my post on entity framework quick start. .

Implementing a Reusable Validation Framework

Image
Validation is an ubiquitous process in all web applications. In this post we will talk about implementing part of a simple validation framework that can be reused in any application.