Prado\Web\UI\WebControls\TCompareValidator::evaluateIsValid PHP 메소드

evaluateIsValid() 공개 메소드

The validation succeeds if the input data compares successfully. The validation always succeeds if ControlToValidate is not specified or the input data is empty.
public evaluateIsValid ( ) : boolean
리턴 boolean whether the validation succeeds
    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;
    }