Extending the Validation Application Block

Retired Content

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.

You extend the Validation Application Block through designated extension points. Typically, these are custom classes written by you that implement a particular interface or derive from an abstract class. Because these custom classes exist in your application space, you do not have to modify or rebuild the Validation Application Block; instead, you can designate your extensions through configuration settings.

You can extend the Validation Application Block by implementing new validators. You can create your own Validator classes and your own attributes if the ones provided with the Validation Application Block do not fit your requirements. These classes could validate data types in new ways or they could deal with more complex data types, such as a Customer data type that includes many different data types. For an example of a custom validator, see the DivisibleByValidator class in the Validation QuickStart.

To create your own attributes, create a class that derives from the ValidatorAttribute base class.

There are several approaches to creating your own validators. One approach is to create a class that inherits from the Validator<T> base class or from the Validator class. The first class is for strongly typed validators and the second is for loosely typed validators.