public function evaluateIsValid()
{
if (($value = $this->getValidationValue($this->getValidationTarget())) === '') {
return true;
}
if (($controlToCompare = $this->getControlToCompare()) !== '') {
if (($control2 = $this->findControl($controlToCompare)) === null) {
throw new TInvalidDataValueException('comparevalidator_controltocompare_invalid');
}
if (($value2 = $this->getValidationValue($control2)) === '') {
return false;
}
} else {
$value2 = $this->getValueToCompare();
}
$values = $this->getComparisonValues($value, $value2);
switch ($this->getOperator()) {
case TValidationCompareOperator::Equal:
return $values[0] == $values[1];
case TValidationCompareOperator::NotEqual:
return $values[0] != $values[1];
case TValidationCompareOperator::GreaterThan:
return $values[0] > $values[1];
case TValidationCompareOperator::GreaterThanEqual:
return $values[0] >= $values[1];
case TValidationCompareOperator::LessThan:
return $values[0] < $values[1];
case TValidationCompareOperator::LessThanEqual:
return $values[0] <= $values[1];
}
return false;
}