Skip to content

[Validator] String normalization options for string-based validators #26484

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

Merged
merged 1 commit into from
Mar 31, 2019

Conversation

renan-taranto
Copy link
Contributor

@renan-taranto renan-taranto commented Mar 11, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #26239
License MIT
Doc PR symfony/symfony-docs#9433

Todo:

  • Document the new options
  • Update Doc PR

Add trimming options to the string constraints.

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Mar 12, 2018
@renan-taranto renan-taranto force-pushed the string_normalization_options branch from 535259e to 4194fcf Compare March 12, 2018 23:37
@Destroy666x
Copy link

Destroy666x commented Mar 13, 2018

Looks good now, thanks. Some more edge cases (e.g. regular whitespaces) could be added for tests, but not sure how strict are they here yet

@renan-taranto renan-taranto changed the title [WIP] [Validator] String normalization options for string-based validators [Validator] String normalization options for string-based validators Mar 13, 2018
@renan-taranto
Copy link
Contributor Author

renan-taranto commented Mar 13, 2018

Thanks for the review @Destroy666x.

@renan-taranto renan-taranto force-pushed the string_normalization_options branch from 4194fcf to d1a0c02 Compare March 14, 2018 20:39
@renan-taranto renan-taranto force-pushed the string_normalization_options branch from d1a0c02 to 8e6a52f Compare March 22, 2018 02:01
@renan-taranto renan-taranto changed the title [Validator] String normalization options for string-based validators [WIP][Validator] String normalization options for string-based validators Mar 22, 2018
@xabbuh
Copy link
Member

xabbuh commented Apr 1, 2018

Would it make sense to update other constraint validators too?

@renan-taranto
Copy link
Contributor Author

Hey guys, how do you like this PR right now?

@fabpot fabpot modified the milestones: 4.1, next Apr 22, 2018
@nicolas-grekas nicolas-grekas changed the title [WIP][Validator] String normalization options for string-based validators [Validator] String normalization options for string-based validators Jun 19, 2018
@xabbuh
Copy link
Member

xabbuh commented Jun 19, 2018

@renan-taranto For consistency, I would add this option to the other string constraints too.

@renan-taranto renan-taranto force-pushed the string_normalization_options branch from 8e6a52f to c21460a Compare June 19, 2018 21:35
@renan-taranto renan-taranto force-pushed the string_normalization_options branch from a299b0b to 795acf3 Compare September 13, 2018 23:28
@renan-taranto renan-taranto force-pushed the string_normalization_options branch from 795acf3 to a53a1fc Compare October 7, 2018 23:10
@gmponos
Copy link
Contributor

gmponos commented Oct 9, 2018

Hello,

for me as a developer using symfony the normalizer option is a little bit confusing. I am referring to the naming of it. Maybe it's because in the syfmony world when I hear normalizer my mind goes to the Serializer component. So in the end when I saw the title of this PR I was expecting to see about an option that will be able to convert objects into strings and remove this code:

       if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {

I am not sure if the same confusion will be caused later for whatever reason. Therefore my suggestion would be formatter. Or simple trim and allowing this option to be either true or callable and if it is true just use plain trim. It's just a suggestion your call :)

@ostrolucky
Copy link
Contributor

You can pass even callable which makes input pass the above check, it's your choice. Hence formatter is not good name.

@renan-taranto renan-taranto force-pushed the string_normalization_options branch from 5d31a78 to 9da6661 Compare October 9, 2018 23:20
@renan-taranto
Copy link
Contributor Author

PR updated. AppVeyor broke due to the unrelated Symfony\Component\Process\Tests\ProcessTest.

@renan-taranto renan-taranto force-pushed the string_normalization_options branch from 9da6661 to 3a06897 Compare October 29, 2018 22:36
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please and a line in the changelog of the component?

@renan-taranto renan-taranto force-pushed the string_normalization_options branch from 3a06897 to 202d8a2 Compare December 1, 2018 12:47
@renan-taranto
Copy link
Contributor Author

Hi @nicolas-grekas, is there anything else I can do for this PR?

@nicolas-grekas nicolas-grekas force-pushed the string_normalization_options branch from 7127d15 to 708d759 Compare March 13, 2019 15:39
@fabpot
Copy link
Member

fabpot commented Mar 31, 2019

Thank you @renan-taranto.

@fabpot fabpot merged commit 708d759 into symfony:master Mar 31, 2019
fabpot added a commit that referenced this pull request Mar 31, 2019
…sed validators (renan-taranto)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[Validator] String normalization options for string-based validators

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26239
| License       | MIT
| Doc PR        | symfony/symfony-docs#9433

Todo:
- [x] Document the new options
- [x] Update Doc PR

Add trimming options to the string constraints.

Commits
-------

708d759 [Validator] String normalization options for string-based validators
@renan-taranto renan-taranto deleted the string_normalization_options branch March 31, 2019 20:17
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Apr 24, 2019
This PR was merged into the master branch.

Discussion
----------

[Validator] Document the "normalizer" option

Documents the PR symfony/symfony#26484

Commits
-------

6eec07b [Validator] Document the "normalizer" option
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
@fabpot fabpot mentioned this pull request May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.