probklem with validating a list

probklem with validating a list

Old forum URL:

jbarrett posted on Thursday, June 06, 2013

I need to validate a list such that all rows are valid as long as one row is valid. How do I do that if I can not clear the broken rules?

JonnyBee replied on Thursday, June 06, 2013

Ill add this from the other post you made:


I have a list. In that list there is a Boolean field and only one row in the list can have that Boolean turned on. I thought I wanted to have a rule to validate. But the problem is, every row in the list shows an error (red 'x') even when one row has a valid value. How to I cross-validate other rows? I thought I should clear the broken rules upon each validate call, but since I can not clear out the broken rules, how do I do it? Or is there some other way to handle validation an entire list of data such that all rows are valid if any one row is valid?

In general - I would add code to clear the flag on all other items in the list when one item gets its boolean flag checked rather than have a broken rule on all objects except the one that has been selected. You can accomplish this by overriding the ChildChanged method/event on the list. So my preference is that the code should make sure that only one item can ever be selected in the list.

The BrokenRules collection of a business object must always reflect the result of the rules - it is not allowed to clear all the BrokenRules and potentially enter a very falsely valid state.

Another option is to add a rule in the "parent" object of the list that only one item is allowed to be checked or one item must be checked. This rule must be called in your code in the ChildChanged event on the Parent.

You should _NOT_ do cross validation within the list. Rules validate each item in the list and ahould not be dependent on all the other items in the list.



Copyright (c) Marimer LLC