Share via


The Effects of the Validation Handler

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.

The third method of the business object, GetCustomerDetails, carries a ValidationCallHandler attribute that specifies the length of the String parameter passed to the method. Attempts to execute the method with an input value that is not five characters long results in an error message generated by the Validation Handler. The ValidationCallHandler attribute adds this handler to the handler pipeline for the GetCustomerDetails method. Figure 1 illustrates the result.

Ff648177.27c809e9-54f5-4693-adb6-6bf9b0e2d7ed(en-us,PandP.10).png

Figure 1
The Validation Handler and a directly approved attribute provide parameter validation

Administrators and operators can add the Validation Handler to the pipeline using the configuration system (Web.config), but it is generally better to use attributes. Usually, the developer will know the limitations of a method or algorithm at design time and can apply the appropriate attributes to validate input. However, keep in mind that the .NET Framework does not guarantee the order in which multiple attributes will be retrieved, so you should always specify the Order property of each one where the order in which the handlers are executed is considered critical.