Is there anyway to add a validation Message to a model object

Topics: Developer Forum
Feb 5, 2008 at 4:46 AM
Hi,

Is there anyway to add a validation Message to a model object ... ie

public override bool IsValid
{
get
{
bool isValid = base.IsValid;

if (!PostalAddress.IsValid)
{
foreach (ValidationResult validationResult in PostalAddress.ValidatorResultsInError)
{
base.ValidatorResultsInError.Add(validationResult);
}
isValid = false;
}
return isValid;
}
}

If there are error messages in the child object I want to add them to the parent model so they are reported in the UI. The above code compiles and runs but the base.ValidatorResultsInError.Add(validationResult); doesn't add the error to the collection

???

Cheers
Adam