#102326Allow custom translation keys for extbase validators
Description
Extbase validators do currently use hardcoded translation keys to output possible validation messages. Those translation keys can globally be overwritten using a custom localization file, but it is not possible to provide individual translation keys for validation errors in a given context (e.g. property or dedicated validator call).
There is a workaround (https://stackoverflow.com/a/40400270/1744743) out there, which uses fluid and the given error codes of the extbase validators. This works fine, but I think extbase should provide something out of the box in order to define translation keys in code as shown below:
#[Validate([
'validator' => 'NotEmpty',
'options' => [
'nullTranslateKey' => 'validation.title.notNull',
'emptyTranslateKey' => 'validation.title.notEmpty',
'extensionName' => 'my_extension'
],
])]
protected string $title = '';Reviews 6
- main 86877[BUGFIX] Fix shorthand translation key handling in extbase validators
- 13.4 86901[BUGFIX] Fix shorthand translation key handling in extbase validators
- main 86874[BUGFIX] Properly enable 'translationOption' for all validators
- 13.4 86859[BUGFIX] Properly enable 'translationOption' for all validators
- main 86798[!!!][TASK] Remove RegularExpressionValidator option "errorMessage"
- main 81696[FEATURE] Allow custom translations for extbase validators