Project

General

Profile

Actions

Feature #102326

open

Allow custom translation keys for extbase validators

Added by Torben Hansen 7 months ago. Updated 17 days ago.

Status:
Under Review
Priority:
Should have
Assignee:
Category:
-
Target version:
Start date:
2023-11-06
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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 = '';
Actions

Also available in: Atom PDF