schmittjoh / JMSTranslationBundle

Puts the Symfony2 Translation Component on steroids
http://jmsyst.com/bundles/JMSTranslationBundle
427 stars 291 forks source link

Prevent all non message Form Constraint option from being extracted #554

Closed nfragnet closed 3 years ago

nfragnet commented 3 years ago
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #553
License Apache2

Description

The goal of this PR is to filter Form Constraint options to extract. Some of these options are values and are not meant to be extracted.

I assumed that only the option ending with the string message should be extracted because this pattern seems pretty correct for all predefined Constraints, plus it keeps extracting options of custom constraints ending with 'message'.

Example

new Assert\Length([
    'min' => 5,
    'max' => 50,
    'minMessage' => 'length.min.message',
    'maxMessage' => 'length.max.message',
]),
new Assert\Regex([
    'pattern' => '/,/',
    'match' => false,
    'message' => 'regex.message',
]),

Only those three keys should be extracted :

Currently the number 5, the number 50 and the pattern string are extracted too.

Please tell me if the way I filter those options need to be improved.

Todos