Is it possible to use this module to verify sum of all values in multi-value integer field? For example, if I have a multi-value integer field where each cardinal value represents a percentage, I don't want the user to be able to enter a set of values that sums > 100.

Can this module be used to validate the sum of all values in a multi-value field? If so, how?

If not, how difficult would it be to achieve this? Creative recipes welcome.

Comments

lunk rat’s picture

Issue summary: View changes
g089h515r806’s picture

you could use php validator, here is some sample code:

$total = 0;
foreach($this->items as $item){
 $total = $total + $item['value'];
}
if($total > 100){
$this->set_error();
}
lunk rat’s picture

Thank you g089h515r806—I will use the PHP validator. And thanks for the sample code!