ObjectCollectionValidator - how to get the validated object from ValidationResults

Topics: Validation Application Block
Aug 8, 2007 at 2:59 PM
For example I want to Validate a Person object that contains an Adresses collection.
Lets say an address has a mandatory StreetName property.
Now I fill the Addresses collection with 3 Addresses and I leave the StreetName property empty for the first and last address.
After Validating I will get two validation results with 'StreetName' as key.
How can I know from the validation results which address object in the collection are wrong ?
Aug 8, 2007 at 3:43 PM
Just found what I'm looking for in the Target property
Sep 19, 2007 at 8:15 PM
Though the Target property does tell you what type the object the validation was done on, it would still be nice to be able to obtain the actual property name or the Tag name from the validator itself. If I have a Person object that has two collections, CurrentAddresses and OldAddresses, both a collection of Addresses, and it is determined that one is incorrect in the OldAddresses, it would be nice to be able to show that to the user so that don't necessarily have to look at both address collections to see where the validation was incorrect - it would give them a quicker way of getting to the result. This could also be said for an ObjectValidator as well.
Sep 20, 2007 at 12:24 PM
But then, with a deeper hiearchy, you need to be able to specify the full path that led to this object in error.
Sep 20, 2007 at 8:46 PM
Agreed. I don't see a necessarily problem with that....currently one would have a harder time trying to decipher where the actual error is happening now. It would be up to the developer to decide what and how to show where the error occurred in this complexity.