Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 13, 2020
Merged

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

merged 1 commit into from
Dec 13, 2020

Conversation

nfragnet
Copy link
Contributor

@nfragnet nfragnet commented Dec 10, 2020

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 :

  • 'length.min.message'
  • 'length.max.message'
  • 'regex.message'

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

  • Tests
  • Documentation
  • Changelog

@goetas goetas merged commit de63a3e into schmittjoh:master Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants