Suggestion on additinal use for VAB

Topics: Validation Application Block
Mar 8, 2007 at 11:49 AM
Warnings :)

1. I assign a validator and mark it to not fail validation and generate a Warning instead.
2. I call Validation.Validate() as ussual and let's say it fails.
3. I have IsValid true and free ValidationResults but have ValidationResults.HasWarnings true and ValidationResults.Warnings collection filled out with one ValidationResult.
4. Then I'm able to log this warning or something else.


Possible scenarios are not permanent tracking for user input and testing "would-be" validators before being applied in production.

1. For instance, I assign additional validator to the Name property in production and monitor during a month through a log how many people tried to be Michael Jackson or George Michael during the next month. But both names are valid for the system.

2. I want to add an additinal validator to the property that might dramatically restrict the use of object and I just add it as a warning and perform some testing to be sure that the other components of system pass data already withing new bounds and if that's ok I change this validator to produce failures.


I also think that the possibility to forward validation results to Logging Application Block the way similar to how PIAB's LogCallHandler works might be a good idea.


Thanks,
Leonid
Mar 8, 2007 at 4:07 PM
Hi Leonid -

Check out the Tag property that you can configure on each validator - this is designed for this kind of scenario. If you set the Tag on some of your validators to "Warning" and some to "Critical", you can then filter the results like this:
ValidationResults results = validator.Validate(stuff);
ValidationResults warnings = results.FindAll("Warning");
ValidationResults errors = results.FindAll("Critical");

Does this work for you?
Tom