The Validation Application Block
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
|The latest Enterprise Library information can be found at the Enterprise Library site.|
The Enterprise Library Validation Application Block provides useful features that allow developers to implement structured and easy-to-maintain validation scenarios in their applications. Any application that accepts input either from users or from other systems must ensure that the information is valid in terms of some set of rules that you specify. For example, when processing an order, you may need to check that a customer's phone number has the correct number of digits or that a date falls within a particular range. In addition, if the validation fails, you may need to send an error message that explains what is wrong.
The Enterprise Library Validation Application Block provides a library of classes named validators, which implement functionality for validating .NET Framework data types. For example, one validator checks for null strings and another validator checks that a number falls within a specified range.
There are also special validators named AndCompositeValidator and OrCompositeValidator. If you create an AndCompositeValidator, which aggregates other validators, all validators in the composite validator must return True for successful validation. If you create an OrCompositeValidator, at least one of the validators in the composite validator must return True for successful validation.
You can also group validators together in a rule set. A rule set allows you to validate a complex object or graph by composing different validators of different types and applying them to elements in the object graph. Examples of these elements include fields, properties, and nested objects.
By using the Validation Application Block, you can perform validation and create rule sets in the following three ways:
- Using configuration
- Using attributes
- Using code
In addition, the Validation Application Block includes adapters that allow you to use the application block with the following technologies:
- Windows Forms
- Windows Communications Framework (WCF)
This section includes the following topics:
- Introduction to the Validation Application Block
- Developing Applications Using the Validation Application Block
- Key Scenarios
- Design of the Validation Application Block
- Extending and Modifying the Validation Application Block
- Deployment and Operations
- Validation QuickStart
For related information, see the following patterns & practices guides:
- PowerPoint Presentation: Introducing the Validation Application Block
- How To: Protect From Injection Attacks in ASP.NET
- Security Practices: ASP.NET 2.0 Security Practices at a Glance