Feature: #91719 - Custom error messages in RegularExpressionValidator
See forge#91719
Description
The
Regular
can now return a custom validation error message
to help the user providing valid input.
Impact
A new option
error
has been introduced to the validator.
Example:
class MyModel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var string
* @TYPO3\CMS\Extbase\Annotation\Validate(
* "RegularExpression",
* options={
* "regularExpression": "/^SO[0-9]$/",
* "errorMessage": "explain how to provide a valid value"
* }
* )
*/
protected $customField;
}
Copied!
It is also possible to provide a translation key to render a localized message:
class MyModel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var string
* @TYPO3\CMS\Extbase\Annotation\Validate(
* "RegularExpression",
* options={
* "regularExpression": "/^SO[0-9]$/",
* "errorMessage": "LLL:EXT:my_extension/path/to/xlf:translation.key"
* }
* )
*/
protected $customField;
}
Copied!
If no
error
is provided, the default message will be displayed in case of a validation error.