Understanding Validation Results

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 ValidationResults type is a collection of ValidationResult objects. Each ValidationResult object contains a report that includes references to the Validator instance, the object that was validated, and error messages.

The ValidationResults.FindAll method filters a ValidationResult object and eliminates results that do not match the tags provided by the user. This method returns a new ValidationResults object that contains the desired information and leaves the original object unchanged.

The ValidationResults.IsValid property returns True if the validation passed and returns False if the validation failed.

The following table lists the properties of the ValidationResult class.

Property

Description

IsValid

This property returns True if validation succeeded or False if validation failed.

Key

This is a name that describes the location of the validation result. It contains the name of the member that is associated with the validator. It is null if the validator is defined at the type level.

Object

This is the object that was validated.

Message

This is a message that describes the validation failure.

Tag

This is a value supplied by the user as the Tag property of the validator. Typically, it is used for categorization or filtering. The tag can be supplied through the constructor but it is typically set either by using a property in the validation attributes or with configuration.

Target

This is the object to which the validation rule was applied.

Validator

This is the validator that performed the validation.