通过当前规则验证属性，如果有验证不通过的情况，将通过 model 的 addError 方法添加错误信息
@param \Abstracts\Model $object
@param string $attribute
@throws \Exception
187187
protected function validateAttribute($object, $attribute)
    {
        $value = $object->{$attribute};
        if ($this->isEmpty($value)) {
            $this->validateEmpty($object, $attribute);
            return;
        }
        if (!is_array($this->range)) {
            throw new Exception('属性"range"必须定义为数组', 101400301);
        }

        if (is_array($value)) {
            $noIn = [];
            foreach ($value as $v) {
                if (false === $this->inArray($v)) {
                    $noIn[] = $v;
                }
            }
            $isIn = empty($noIn);
        } else {
            $isIn = $this->inArray($value);
        }

        if (!$isIn) {
            $this->addError($object, $attribute, $this->message);
            return;
        }
    }
768092
public function isFirstErrorAttribute($attribute) {
		if($this->_firstErrorAttribute === false) {
			$errorAttributes = array_keys($this->firstErrors);
			$this->_firstErrorAttribute = array_shift($errorAttributes);
		}

		return $attribute == $this->_firstErrorAttribute;
	}
938038
protected function bindAttr($model, &$result)
    {
        foreach ($this->bindAttr as $key => $attr) {
            $key = is_numeric($key) ? $attr : $key;
            if (isset($result->$key)) {
                throw new Exception('bind attr has exists:' . $key);
            } else {
                $result->setAttr($key, $model ? $model->$attr : null);
            }
        }
    }
300284
protected function validateAttribute($object, $attribute)
    {
        $value = $object->{$attribute};
        if ($this->isEmpty($value)) {
            $this->validateEmpty($object, $attribute);
            return;
        }
        if (
            (!$this->strict && $value != $this->trueValue && $value != $this->falseValue)
            || ($this->strict && $value !== $this->trueValue && $value !== $this->falseValue)
        ) {
            $this->addError($object, $attribute, $this->message, [
                '{true}' => $this->trueValue,
                '{false}' => $this->falseValue,
            ]);
        }
    }
326138
protected function loadModelsManyToManyViaTable($attribute)
    {
        $data = $this->relationalData[$attribute];

        $activeQuery = $data['activeQuery'];
        /** @var ActiveRecord $class */
        $class = $activeQuery->modelClass;

        $via = $activeQuery->via;
        $data['junctionTable'] = $via->from[0];

        list($data['junctionColumn']) = array_keys($via->link);
        list($data['relatedColumn']) = array_values($activeQuery->link);
        $junctionColumn = $data['junctionColumn'];
        $relatedColumn = $data['relatedColumn'];

        if (!empty($data['data'])) {
            // make sure what all row's ids from POST exists in database
            $countManyToManyModels = $class::find()->where([$class::primaryKey()[0] => $data['data']])->count();
            if ($countManyToManyModels != count($data['data'])) {
                throw new RelationException('Related records for attribute ' . $attribute . ' not found');
            }
            // create new junction rows
            foreach ($data['data'] as $relatedModelId) {
                $junctionModel = array_merge(
                    !ArrayHelper::isAssociative($via->on) ? [] : $via->on,
                    [$junctionColumn => $this->owner->getPrimaryKey()]
                );
                $junctionModel[$relatedColumn] = $relatedModelId;
                if (isset($this->relations[$attribute]) && is_callable($this->relations[$attribute])) {
                    $junctionModel = call_user_func($this->relations[$attribute], $junctionModel, $relatedModelId);
                }
                $data['newRows'][] = $junctionModel;
            }
        }

        if (!empty($this->owner->getPrimaryKey())) {
            $data['oldRows'] = (new Query())
                ->from($data['junctionTable'])
                ->select(array_merge(
                        [$junctionColumn, $relatedColumn],
                        !ArrayHelper::isAssociative($via->on) ? [] : array_keys($via->on))
                )->where(array_merge(
                    !ArrayHelper::isAssociative($via->on) ? [] : $via->on,
                    [$junctionColumn => $this->owner->getPrimaryKey()]
                ))->all();
        }

        $this->relationalData[$attribute] = $data;
    }
748329
public function passes($attribute, $value)
    {
        $this->failed = false;

        $this->callback->__invoke($attribute, $value, function ($message) {
            $this->failed = true;

            $this->message = $message;
        });

        return ! $this->failed;
    }
798834
public function setAttribute($attribute, $value) {
		if (!array_key_exists($attribute, $this->_readonlyAttributes)) {
			$this->_attributes[$attribute] = $value;
			return true;
		}

		return false;
	}
197043
public function reset ($name)
	{
		
		// If the attribute doesn't exists
		
		if (!$this->attributeExists ($name))
		{
			throw new Exception (get_called_class () . '->' . $name . ' attribute does not exist!');
		}
		
		// If attribute reset is disabled
		
		if (!$this->attributeReset ($name))
		{
			throw new Exception (get_called_class () . '->' . $name . ' attribute reset is disabled!');
		}
		
		// If there is no default attribute value remove the value
		
		if (!array_key_exists ('default', static::$attributes[$name]))
		{
			unset ($this->attributeValues[$name]);
		}
		
		// Else there is a default attribute value so set it
		
		else
		{
			$this->iset ($name, static::$attributes[$name]['default'], FALSE);
		}
		
	}
121874
protected function addError($attribute, $message)
    {
        if (!isset($this->errors[$attribute])) {
            $this->errors[$attribute] = array();
        }
        $this->errors[$attribute][] = $message;
    }
1349885
protected function _throw($object)
    {
        $error = $object->errorInfo();
        throw new \RuntimeException(
            sprintf(
                'PDO operation returned SQLSTATE %s: Error %s (%s)',
                $error[0],
                $error[1],
                $error[2]
            )
        );
    }
1336198
public function setValue($object = null, $value = null)
    {
        if (!is_object($object)) {
            throw new Exception('$object is of type ' . gettype($object) . ', instance of class ' . $this->class . ' expected.', 1210859212);
        }

        if ($this->isPublic()) {
            parent::setValue($object, $value);
        } else {
            parent::setAccessible(true);
            parent::setValue($object, $value);
        }
    }
566490
public function getAttribute($attribute)
    {
        if (!isset($this->attributes[$attribute])) {
            throw new EntityException(EntityException::ATTRIBUTE_NOT_FOUND, [
                $attribute,
                get_class($this)
            ]);
        }

        return $this->attributes[$attribute];
    }
1360634
public function escapeHtmlAttribute($attribute)
    {
        if (!$this->escapeHtmlAttrHelper) {
            $this->escapeHtmlAttrHelper = $this->getView()->plugin('escapehtmlattr');
            if (!$this->escapeHtmlAttrHelper instanceof EscapeHtmlAttr) {
                throw new Exception\RuntimeException('Helper not loaded: escapeHtmlAttr');
            }
        }
        return $this->escapeHtmlAttrHelper->__invoke($attribute);
    }
33119
public static function isActiveRecord($object, $throwException=false)
	{
		if ($object instanceof \yii\db\ActiveRecord) return true;
		if ($throwException) {
			$msg = Yii::t('app', 'Object {obj} does not extend ActiveRecord', ['obj'=>get_class($object)]);
			throw new InvalidConfigException($msg);
		}

		return false;
	}
284401
private function handleObject($object, $type=null) {
        if (is_object($object)) {
          if (!($object instanceof BaMLAttribute || $object instanceof BaMLText || $object instanceof BaMLVerb)) {
            throw new \CatapultApiException("Not a valid object in BaML schema. Must be either BaMLAttribute, BaMLVerb or BaMLVerb");
          }
          if (!isset($this->currentVerb)) {
            $this->setCurrentVerb($object);
          }
          if (!isset($this->currentText)) {
            $this->setCurrentText($object);
          }
           
          $this->addData($object);
        } else {
            /** for this initialization we need type to be set **/
          $this->addData($object); 
        }
    }
297999
public function getAttribute($attribute)
    {
        if (! isset($this->attributes[$attribute])) {
            throw new \Exception('Attribute "'.$attribute.'" is not set');
        }
        $this->attributes[$attribute];
    }
139488
public function update($object)
    {
        try {
            $this->dm->persist($object);
            $this->dm->flush();
        } catch (\Exception $e) {
            throw new ModelManagerException('', 0, $e);
        }
    }