Validates user email to ensure that only one user exist with the given email.

@param type $attribute
@param type $params
@return void
487734
public function validateEmailUpdate( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			$existingUser = self::findByEmail( $this->email );

			if( isset( $existingUser ) && $this->id != $existingUser->id ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_EMAIL_EXIST ) );
			}
		}
	}
51825
public function validateEmails($attribute)
    {
        $items = $this->$attribute;

        if (!is_array($items)) {
            $items = [];
        }

        foreach ($items as $index => $item) {
            $validator = new EmailValidator();
            $error = null;
            $validator->validate($item, $error);
            if (!empty($error)) {
                $key = $attribute . '[' . $index . ']';
                $this->addError($key, $error);
            }
        }
    }
531011
public function password($attribute, $params)
	{
		$this->attributes[$attribute] = $this->$attribute = Cii::encrypt($this->$attribute);
		return true;
	}
1275972
protected function validateExists($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'exists');

        list($connection, $table) = $this->parseTable($parameters[0]);

        // The second parameter position holds the name of the column that should be
        // verified as existing. If this parameter is not specified we will guess
        // that the columns being "verified" shares the given attribute's name.
        $column = isset($parameters[1]) ? $parameters[1] : $attribute;

        $expected = (is_array($value)) ? count($value) : 1;

        return $this->getExistCount($connection, $table, $column, $value, $parameters) >= $expected;
    }
1217316
public function validateReservedWord($attribute,$params)
	{
		$value=$this->$attribute;
		if(in_array(strtolower($value),self::$keywords))
			$this->addError($attribute, $this->getAttributeLabel($attribute).' cannot take a reserved PHP keyword.');
	}
1044559
public function validateSlugCreate( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			if( self::isExistBySlug( $this->slug ) ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_SLUG_EXIST ) );
			}
		}
	}
892091
protected function validateRegex($attribute, $value, $parameters)
    {
        if (! is_string($value) && ! is_numeric($value)) {
            return false;
        }

        $this->requireParameterCount(1, $parameters, 'regex');

        return preg_match($parameters[0], $value);
    }
1294049
public function validateIn($attribute, $value, $parameters)
    {
        if (is_array($value) && $this->hasRule($attribute, 'Array')) {
            foreach ($value as $element) {
                if (is_array($element)) {
                    return false;
                }
            }

            return count(array_diff($value, $parameters)) === 0;
        }

        return ! is_array($value) && in_array((string) $value, $parameters);
    }
1112260
public function validateUsernameUpdate( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			$existingUser = self::findByUsername( $this->username );

			if( isset( $existingUser ) && $this->id != $existingUser->id ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_USERNAME_EXIST ) );
			}
		}
	}
1125180
public function validateUsername( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			if( $this->userService->isExistByUsername( $this->username ) ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_USERNAME_EXIST ) );
			}
		}
	}
1201616
public function already_selected($attribute, $params)
    {
        if($this->$attribute && $this->find()->where($attribute . '=' . $this->$attribute . 
            ($this->id ? ' and id <> ' . $this->id : '')
        )->one())
            $this->addError($attribute, $params['message']);
    }
339297
public function validOneTimePassword($attribute, $params)
    {
        if (($behavior = $this->getBehavior('oneTimePasswordBehavior')) !== null) {
            return $behavior->validOneTimePassword($attribute, $params);
        }

        return true;
    }
1227421
public function normalizeTags($attribute,$params)
	{
		$this->tags=Tag::array2string(array_unique(Tag::string2array($this->tags)));
	}
552844
protected function validateAttribute (string $attribute=NULL) : bool
	{
		if (!property_exists($this, $attribute))
		{
			$this->error = "Attribute: ".ucfirst($attribute)." is not a class object.";
        	return FALSE;
		}
        $result = (is_array($this->$attribute)) ? !empty($this->$attribute) : Validate::hasValue($this->$attribute);
        if ($result) return TRUE;
		$this->error = "Set ".ucfirst($attribute)." to log your message.";
    	return FALSE;
	}
442832
public function uniqueForEntity($attribute, $params)
    {
        $translationsIds = ProductTranslation::find()
            ->asArray()->where(['product_id' => $this->product_id])->select('id')->all();

        $seoUrl = SeoData::find()
            ->where(['entity_name' => ProductTranslation::className(), 'seo_url' => $this->seoUrl])
            ->andWhere(['not in', 'entity_id', ArrayHelper::getColumn($translationsIds, 'id')])
            ->one();

        if (!empty($seoUrl)) {
            $this->addError($attribute, \Yii::t('shop', 'Such url already exists'));
        }
    }
247682
public function authenticate($attribute, $params)
    {
        if ($this->hasErrors()) {
            return false;
        }
        if (($identity = $this->getIdentity()) === null) {
            throw new \yii\base\Exception('Current user has not been found in the database.');
        }
        if (!$identity->verifyPassword($this->$attribute)) {
            $this->addError($attribute, Yii::t('usr', 'Invalid password.'));

            return false;
        }

        return true;
    }
1229781
protected function validateAttribute($object, $attribute)
    {
        $value = $object->$attribute;

        if ($value) {

            if (!preg_match('/^(us|sa|eu|ap)-(north|south|central)?(east|west)?-[1-9]$/', $value)) {
                $this->addError($object, $attribute, 'Please enter a valid AWS region e.g us-east-1.');
            }
        }
    }