/** * Adds an error about the specified attribute to the active record. * This is a helper method that performs message selection and internationalization. * * @param \Model $object the data object being validated * @param string $attribute the attribute being validated * @param string $message the error message * @param array $params values for the placeholders in the error message */ protected function addError($object, $attribute, $message, $params = []) { $params['{attribute}'] = $object->getAttributeLabel($attribute); $object->addError($attribute, strtr($message, $params)); }