Monday, August 16, 2010

The Validation Application Block




Recently I've been refactoring some monolithic project. I'm trying to make it more modular, easier to manage. I'm dividing code into smaller projects base on business logic (parts of code that can be made module base on some autonomous functionality, and are not really strongly connected to the application base) and based on architectural modules - like separate project for a database layer, separate for managers... one of those smaller projects are validators. There are so many different ways of validating input in the application. It's shocking, each time somebody inputs a date into the system, it is validated in a different way, not to mention that there is no such a thing like a common date format, or error message format. This is where 'Validators' module kicks in, it is supposed to be the only place that is responsible for keeping some regular expressions, configurations, validation methods that are related with validation and are not included in a base (in my case that do not exist in a System.ComponentModel.DataAnnotations). I really enjoy the idea of validating input by using annotations. My research on different annotation based validation frameworks lead me to Validation Application Block.

As for me it gives more possibilities available out of the box to validate input then DataAnnotations, but it doesn't integrate MVC validation framework. I had to write adapters in order to connect both frameworks.

If you haven't seen it, give it a shot.

No comments: