Problem: ObjectValidator And Specifying Attributes vs. Configuration

Topics: Validation Application Block
Mar 20, 2007 at 8:44 PM
I discovered an interesting problem when writing the example in the following Thread:

VAB Object Validator results and configuration problem.

If you validate the Customer Class and specify the validators should come from attributes like:

Validator<Customer> validator = ValidationFactory.CreateValidatorFromAttributes<Customer>();
ValidationResults results = validator.Validate(customer);

The Address Class inside the Customer Class doesn't get the only from attributes information and Address Validators in both the attributes and configuration file kick in during validation.

One can't really tell the Address Class to only get validators from attributes, so wouldn't we just assume that since I specified only attributes for the customer class that this would apply to all validation within the hierarchy? My gut is yes :)




David Hayden
Microsoft MVP C#