Enterprise Library 3 (Validation Application Block)

Enterprise Library 3 has been released a few days ago by Microsoft; it includes 2 new application blocks :
The Validation Application Block.
The Policy Injection Application Block.
Here is a first look of the Validation Apllication Block (VAB).
The VAB allows developers to create validation rules that they can use in their applications.
  • Create a project and make a reference to the VAB assembly :

  • Here is a Student class ; we want the Name size to be between 1 and 10 and not null and its Emailaddress to be not null : The VAB provides the appropriate Attributes classes :

  • Now, if we run the following program with a valid student name, but no EmailAddress :

  • We’ll get this :


  • Now if we want to create our own custom validator, for instance we want to validate the email address (let’s say a valid email address must contain a ‘@’); you must first create a validator class and later a validator attribute class ; here is the validator class :
  • And here is the Validator attribute :

  •  There are many other validators…Take a look at the documentation and enjoy !


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s