diff --git a/include/errors/class_SimplePluginCheckError.inc b/include/errors/class_SimplePluginCheckError.inc index de9772773314618b41185152351d1992c5b9454a..c9679e4b3dfe05409c5af64e25119ea695be484c 100644 --- a/include/errors/class_SimplePluginCheckError.inc +++ b/include/errors/class_SimplePluginCheckError.inc @@ -83,4 +83,20 @@ class SimplePluginCheckError extends FusionDirectoryError return [_('Error'), $html, ERROR_DIALOG, $trace]; } + + /*! + * \brief Format error message for invalid value + * + * \param string $error The unescaped text error + * + * \return HTML string + */ + static public function invalidValue(string $error): string + { + return sprintf( + '<b>%s</b> %s', + htmlescape(_('Invalid value:')), + htmlescape($error) + ); + } } diff --git a/include/simpleplugin/attributes/class_IntAttribute.inc b/include/simpleplugin/attributes/class_IntAttribute.inc index bcbfc7008d0223d3640ea347ad8805f5d365b59a..b5218747a7434534ad7d851085c9da2cf8a43e87 100644 --- a/include/simpleplugin/attributes/class_IntAttribute.inc +++ b/include/simpleplugin/attributes/class_IntAttribute.inc @@ -81,13 +81,22 @@ class IntAttribute extends Attribute return $error; } elseif ($this->value !== '') { if (!is_numeric($this->value)) { - return new SimplePluginCheckError($this, sprintf(_('"%s" is not an number'), $this->getValue())); + return new SimplePluginCheckError( + $this, + SimplePluginCheckError::invalidValue(sprintf(_('"%s" is not an number'), $this->getValue())) + ); } if (($this->min !== FALSE) && ($this->value < $this->min)) { - return new SimplePluginCheckError($this, sprintf(_('%s is smaller than %s'), $this->getValue(), $this->min)); + return new SimplePluginCheckError( + $this, + SimplePluginCheckError::invalidValue(sprintf(_('%s is smaller than %s'), $this->getValue(), $this->min)) + ); } if (($this->max !== FALSE) && ($this->value > $this->max)) { - return new SimplePluginCheckError($this, sprintf(_('%s is larger than %s'), $this->getValue(), $this->max)); + return new SimplePluginCheckError( + $this, + SimplePluginCheckError::invalidValue(sprintf(_('%s is larger than %s'), $this->getValue(), $this->max)) + ); } } }