Validates the attribute of the object.
If there is any error, the error message is added to the object.
@param CModel $object the object being validated
@param string $attribute the attribute being validated
@throws CException if invalid operator is used
966085
protected function validateAttribute($object,$attribute)
	{
		$value=$object->$attribute;
		if($this->allowEmpty && $this->isEmpty($value))
			return;
		if($this->compareValue!==null)
			$compareTo=$compareValue=$this->compareValue;
		else
		{
			$compareAttribute=$this->compareAttribute===null ? $attribute.'_repeat' : $this->compareAttribute;
			$compareValue=$object->$compareAttribute;
			$compareTo=$object->getAttributeLabel($compareAttribute);
		}

		switch($this->operator)
		{
			case '=':
			case '==':
				if(($this->strict && $value!==$compareValue) || (!$this->strict && $value!=$compareValue))
					$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be repeated exactly.');
				break;
			case '!=':
				if(($this->strict && $value===$compareValue) || (!$this->strict && $value==$compareValue))
					$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must not be equal to "{compareValue}".');
				break;
			case '>':
				if($value<=$compareValue)
					$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be greater than "{compareValue}".');
				break;
			case '>=':
				if($value<$compareValue)
					$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be greater than or equal to "{compareValue}".');
				break;
			case '<':
				if($value>=$compareValue)
					$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be less than "{compareValue}".');
				break;
			case '<=':
				if($value>$compareValue)
					$message=$this->message!==null?$this->message:Yii::t('yii','{attribute} must be less than or equal to "{compareValue}".');
				break;
			default:
				throw new CException(Yii::t('yii','Invalid operator "{operator}".',array('{operator}'=>$this->operator)));
		}
		if(!empty($message))
			$this->addError($object,$attribute,$message,array('{compareAttribute}'=>$compareTo,'{compareValue}'=>$compareValue));
	}
1357200
public function validateTimeZone($attribute)
    {
        if (!in_array($this->$attribute, timezone_identifiers_list())) {
            $this->addError($attribute, Yii::t('yuncms', 'Time zone is not valid'));
        }
    }
1015558
private function loadValidatorAttribute(array &$property, AttributeItem $attribute)
    {
        /* @var $element Element */
        $type = $attribute->getType();

        $this->loadValidatorType($property, $type, false);

        // Required properties
        if ($attribute instanceof Attribute) {
            if ($attribute->getUse() === Attribute::USE_REQUIRED) {
                $property['validation'][] = [
                    'NotNull' => null
                ];
            }
        }
    }
1213696
protected function validateCpfCnpj($attribute, $value)
    {
        return ($this->validateCpf($attribute, $value) || $this->validateCnpj($attribute, $value));
    }
1152096
public function attributeValidationException(AbstractAttribute $attribute, ValidationException $e)
    {
        $attrException = new AttributeValidationException($e->getMessage());
        $attrException->addError($attribute->getName(), $e->getMessage());

        return $attrException;
    }
891082
protected function validateUsingCustomRule($attribute, $value, $rule)
    {
        if (! $rule->passes($attribute, $value)) {
            $this->failedRules[$attribute][get_class($rule)] = [];

            $messages = (array) $rule->message();

            foreach ($messages as $message) {
                $this->messages->add($attribute, $this->makeReplacements(
                    $message, $attribute, get_class($rule), []
                ));
            }
        }
    }
12038
public function validateAttribute($model, $attribute)
    {
        $country = '';
        if ($this->country !== null) {
            $country = $this->country;
        } elseif ($this->countryAttribute !== null) {
            $country = $model->{$this->countryAttribute};
        } elseif ($this->countryCodeAttribute !== null) {
            $country = $model->{$this->countryCodeAttribute};
        }
        // if empty country and used strict mode
        if (empty($country) && $this->strict) {
            $this->addError($model, $attribute, Yii::t('app', $this->strictModeMessage));

            return false;
        }
        if (empty($country)) {
            return true;
        }
        $phoneUtil = PhoneNumberUtil::getInstance();
        try {
            $numberProto = $phoneUtil->parse($model->$attribute, $country);
            if ($phoneUtil->isValidNumber($numberProto)) {
                if ($this->format) {
                    $model->$attribute = $phoneUtil->format($numberProto, PhoneNumberFormat::INTERNATIONAL);
                }

                return true;
            } else {
                $this->addError($model, $attribute, Yii::t('app', $this->message));

                return false;
            }
        } catch (NumberParseException $e) {
            $this->addError($model, $attribute, Yii::t('app', $this->numberParseExceptionMessage));
        }
    }
1002783
private static function isValidObject($object): bool {
        if (null === $object) {
            return false;
        }
        if (!\is_object($object)) {
            return false;
        }
        return true;
    }
1079454
protected function validateAttribute($object,$attribute)
	{
		if(!$this->setOnEmpty)
			$object->$attribute=$this->value;
		else
		{
			$value=$object->$attribute;
			if($value===null || $value==='')
				$object->$attribute=$this->value;
		}
	}
172361
protected function validateAttribute($object,$attribute) {
        $value=$object->$attribute;
        if($this->allowEmpty && $this->isEmpty($value))
            return;
        elseif(!is_array($value)) {
            $message=$this->message!==null?$this->message:Yii::t('P2Module.p2','{attribute} is not valid.');
            $this->addError($object,$attribute,$message);
        }

        $length=count($value);
        if($this->min!==null && $length<$this->min) {
            $message=$this->tooShort!==null?$this->tooShort:Yii::t('P2Module.p2','{attribute} is too short (minimum is {min} entries).');
            $this->addError($object,$attribute,$message,array('{min}'=>$this->min));
        }
        if($this->max!==null && $length>$this->max) {
            $message=$this->tooLong!==null?$this->tooLong:Yii::t('P2Module.p2','{attribute} is too long (maximum is {max} entries).');
            $this->addError($object,$attribute,$message,array('{max}'=>$this->max));
        }
        if($this->is!==null && $length!==$this->is) {
            $message=$this->message!==null?$this->message:Yii::t('P2Module.p2','{attribute} is of the wrong length (should be {length} entries).');
            $this->addError($object,$attribute,$message,array('{length}'=>$this->is));
        }
    }
122109
public static function validate($operator, $attributeName = 'operator')
    {
        if (!in_array($operator, self::$operators)) {
            throw new \Phramework\Exceptions\IncorrectParametersException(
                [$attributeName]
            );
        }

        return $operator;
    }
634671
protected function validateAttributeInternal($model, $attribute)
    {
        $value = $model->{$attribute};

        $result = ($this->type == FormatHelper::TYPE_LIST)
            ? $this->validateListValue($model, $value)
            : $this->validateValue($value);

        if (!empty($result)) {
            $this->addError($model, $attribute, $result[0], $result[1]);

            return;
        }

        Yii::info('Type validation success'
            . PHP_EOL . "Result value for '$attribute': {$this->filteredAttribute}", __METHOD__);
        $model->{$attribute} = $this->filteredAttribute;
    }
164732
protected function validate($object)
    {
        $object = (object) $object;

        if ($object instanceof $this->is) {
            return $object;
        }

        throw new \DomainException(
            sprintf(
                "The Asset advertised as being of type %s is actually of type %s",
                $this->is,
                get_class($object)
            )
        );
    }
627791
protected function emptyAttribute($object, $attribute)
	{
		if($this->safe) 
			$object->$attribute=null;

		if(!$this->allowEmpty)
		{
			$message=$this->message!==null?$this->message : Yii::t('yii','{attribute} cannot be blank.');
			$this->addError($object,$attribute,$message);
		}
	}
114438
public function validate(Validation $validation, $attribute)
    {
        $value = $validation->getValue($attribute);
        $modelName = $this->getOption('model', null);
        $conditions = $this->getOption('conditions', null);
        $bind = $this->getOption('bind', []);
        $showMessages = $this->getOption('show_messages', true);
        $compareColumn = $this->getOption('compare_column', null);
        $compareWithSensitivity = $this->getOption('compare_with_sensitivity', true);

        /** @var \Phalcon\Mvc\Model $model */
        $model = $this->getModel($modelName);

        if (is_null($conditions)) {
            if (is_null($value)) {
                return false;
            }
            $data = $model::findFirst(["id = ?0", "bind" => $value]);
        } else {
            $data = $model::findFirst(['conditions' => $conditions, 'bind' => $bind]);
        }
        if (!$data) {
            if ($showMessages) {
                $this->addMessageToValidation($validation, 'Invalid :field supplied', $attribute, 'Model');
            }
            return false;
        }

        if ($compareColumn) {
            $value = ($compareWithSensitivity) ? $value : strtolower($value);
            $modelValue = ($compareWithSensitivity) ? $data->{$compareColumn} : strtolower($data->{$compareColumn});
            if ($modelValue != $value) {
                return false;
            }
        }

        return true;
    }
950047
public function validateUrl ($attribute)
		{
			if (!$this->hasErrors())
			{
				if (filter_var($this->$attribute, FILTER_VALIDATE_URL) === false)
					$this->addError($attribute, Yii::tr('{attribute} is not a valid URL.', [ 'attribute' => $this->name ], 'setting'));
			}
		}
956251
public function validatePassword($attribute)
    {
        if (!$this->hasErrors()) {
            $user = $this->user;
            if (empty($user) || !$user->validatePassword($this->password)) {
                $this->addError($attribute, 'Incorrect username or password.');
            }
        }
    }