Validation Application Block Presentation and New Features - Enterprise Library 3.0
by David Hayden
I presented the new Validation Application Block in Enterprise Library 3.0 last night to the Sarasota .NET Developers Group. An expected 1 hour presentation turned into 2 hours as we had a lot of really good discussion on the new block and Enterprise Library 3.0 as a whole. I expect a number of developers will be downloading the latest Enterprise LIbrary 3.0 CTP today based on our discussions last night.
The January CTP was just released on Friday and has a couple of new goodies in it for the Validation Application Block that I added to my list of demos for the presentation.
ASP.NET Integration
Tom mentioned this in an earlier post and you can find a quickstart in the downloads, but this feature is worth repeating :)
There is a new webcontrol that comes with the Validation Application Block called the PropertyProxyValidator. You can find it in the following assembly:
Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet.dll
The purpose of this control is to avoid duplicating your validation rules in 2 places- your web forms and your business classes. Instead of using ASP.NET Validation Controls to repeat the same validation rules on input controls that will be validated again with the same rules on the business class properties they represent, you can instead use the new PropertyProxyValidator control that reads the rules from the business class itself, saving you the step of creating redundant rules and the maintenance headache of managing rules in multiple places.
Here is an example using ValidatorAttributes, but you could also put your validation rules in an external configuration file.

Winforms Integration
You get similar functionality in the Winforms environment with the addition of a new Winform Control, called ValidationProvider, located in the following assembly:
Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WinForms.dll
Again, you just map each UI control to the appropriate business class property to get the validation rules to avoid creating rules in multiple places.

Visual Studio Integrated Configuration Editor Support
The group was also impressed with the new Configuration Editor for Enterprise Library built right into Visual Studio. The editor now supports the Validation Application Block in the new release:


One of the really valuable features of the editor with the Validation Application Block is that you can use it to discover and select types and properties in your application to save you a lot of manual typing:


Conclusion
Thanks to everyone who attended my presentation. I appreciated all the great discussion about Enterprise Library and the positive feedback on my presentation!
by David Hayden