Re: Validation of collection

Re: Validation of collection

Old forum URL: forums.lhotka.net/forums/t/421.aspx


BigRon posted on Tuesday, June 20, 2006

Rocky - I was trying to extract from this thread an answer to this question:  What is the best practice for checking validity among items (child objects) within a collection from the parent object?  Book examples show overriding the base "IsValid" method with mybase.IsValid and mResources.IsValid.  The problem is that using that example does NOT raise validation exceptions if a child object of that child collection is not in accordance with a validation rule.

Are you recommending looping through the child collection items and checking .IsValid for each item to raise the IsValid flag of the collection to false?  Ex:

In Child Collection:

Public Overrides ReadOnly Property IsValid() As Boolean

Get

For Each o_Child As Child In Me

If Not o_Child.IsValid Then

Return False

End If

Next

End Get

End Property

I thought that the framework was designed to "bubble up" these kinds of events.

 

Copyright (c) Marimer LLC