yii\validators\Validator::addError PHP Метод

addError() публичный Метод

This is a helper method that performs message selection and internationalization.
public addError ( Model $model, string $attribute, string $message, array $params = [] )
$model yii\base\Model the data model being validated
$attribute string the attribute being validated
$message string the error message
$params array values for the placeholders in the error message
    public function addError($model, $attribute, $message, $params = [])
    {
        $params['attribute'] = $model->getAttributeLabel($attribute);
        if (!isset($params['value'])) {
            $value = $model->{$attribute};
            if (is_array($value)) {
                $params['value'] = 'array()';
            } elseif (is_object($value) && !method_exists($value, '__toString')) {
                $params['value'] = '(object)';
            } else {
                $params['value'] = $value;
            }
        }
        $model->addError($attribute, Yii::$app->getI18n()->format($message, $params, Yii::$app->language));
    }