This project is read-only.
Project Description
Binding Validators allows the definition of validation rules through the use of Lambda Expressions and also, should you choose, the binding of Web Forms to models with generated Javascript conversions of any defined rules.

This project is separated into two components, one being a validation library that you can tie in to your domain model or service layer. Rules are defined through the use of Lambda Expressions. The second component is an ASP.NET Web Forms model binder. This allows the easy construction of a binder which can take values between an entity of your domain and a Web Form seamlessly.

Model -> Form ->Model Binding

The project was started to combat several aspects of the ASP.NET Web Forms that weren't quite performing what was required. Firstly, when displaying data in a form there are two main ways of databinding. The traditional way is to manually set the values of all form elements from your domain model and then get and parse those values on postback. The other option is to use the databinding abilities of ASP.NET.
The manual way is tedious and hard to maintain, which is where ASP.NET databinding steps in, however the problem here is that there are no compile time checks made. Compile time checks are good, especially when those checks are being made in an area that's not easily unit-testable such as web pages.

Proposed Solution

BindingValidators aims to provide a solution to this by allowing the binding of domain model properties to Web Form fields through Lambda Expressions. This means that you bind a class property to a form field once and then allow the binder to take care of setting, getting, and parsing data when requested.


The second problem is validation of domain models and form data. ASP.NET provides an acceptable validation framework, however for most non-trivial applications a good separation of concerns is desired. Whilst trying to achieve such separation it's clear that validation of domain models can belong in several places, but the user interface is not one of them. If the validation rules are placed into their correct location they can be called from the ASP.NET validators but any client-side validation is then lost. This can be solved through the duplication of validation rules, however as we all know, code duplication causes poor maintainability.

Proposed Solution

BindingValidators aims to provide a solution to this by allowing business rules to be defined in domain or service layer, remaining callable by business logic operations, and also provide generation of client side validation where the rules permit this. This is made possible by using Lambda Expressions to define the validation rules, and then using the form binder mentioned above to inspect those expressions and generate matching Javascript for client-side validation.

Current State

The codebase is currently in the prototype/proof of concept stage. The Web Forms binder works, and validation rules are definable and can be run against a given domain model object. The Lambda Expression parser and Javascript generator is in a working state and work is underway on the final prototype piece to tie those generated rules into Web Forms Binder.

Usage examples will be written up shortly to demonstrate the proposed interface.

Comments, criticism, contributions and ideas are all welcome on this project.

Last edited Aug 4, 2010 at 9:51 PM by CaptainMatt, version 2