Scenarios and Goals
Collapse the table of content
Expand the table of content

Scenarios and Goals

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 Validation Application Block is designed to address the most common tasks developers face when they must validate input either from a user or another system. These tasks are arranged according to scenarios. Each scenario gives an example of a typical way to use the Validation Application Block and shows the code that accomplishes the task.

The scenarios are the following:

  • Using attributes to define validation rules
  • Using configuration to define validation rules
  • Validating objects
  • Using self validation to define validation rules within your classes
  • Integrating the Validation Application Block into the following types of applications:
    • ASP.NET
    • Windows Forms
    • WCF

Determining When to Use the Validation Application Block

The Validation Application Block allows you to encapsulate validation best practices into easily maintainable code that you can reuse. Encapsulation also allows you to separate the application code from the validation logic. In some situations, you may be able to update the validation logic without redeploying the application. Another common situation where the application block works well is when your validation code must work across multiple layers of the application's architecture.

In very simple cases, when you only need to validate a few objects, you may not want to incur the overhead of adding the application block.

Alternatives

Alternatives to using the Validation Application Block may include using the validation capabilities that are a part of ASP.NET and Windows Forms. Another alternative for WCF and other applications that use XML data is to use the XML Schema Definition tool (XSD), which allows you to validate messages at the XML level. If your validation logic only needs to be applied within these technologies you may not need to use the application block. However, if the validation logic needs to be reused, the application block is a better choice.

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.
Show:
© 2016 Microsoft