protected function evaluateIsValid()
{
$control = $this->getValidationTarget();
$exists = true;
$values = $this->getSelection($control);
$count = count($values);
$required = $this->getRequiredValues();
//if required, check the values
if (!empty($required)) {
if ($count < count($required)) {
return false;
}
foreach ($required as $require) {
$exists = $exists && in_array($require, $values);
}
}
$min = $this->getMinSelection();
$max = $this->getMaxSelection();
if ($min !== -1 && $max !== -1) {
return $exists && $count >= $min && $count <= $max;
} else {
if ($min === -1 && $max !== -1) {
return $exists && $count <= $max;
} else {
if ($min !== -1 && $max === -1) {
return $exists && $count >= $min;
} else {
return $exists;
}
}
}
}