10000 [Validator] Reintroduced Range constraint and created Count and Length constraints by webmozart · Pull Request #4863 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Reintroduced Range constraint and created Count and Length constraints #4863

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 4 commits into from
Jul 12, 2012

Conversation

webmozart
Copy link
Contributor

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

After @Tobion's comment to #4851, this is the next try to streamline the constraints and reduce duplication of logic. The downside of the current MinLength/MaxLength and MinCount/MaxCount pairs is that they cannot output a fitting error message if a value should have an exact length/count. So this PR introduces

  • Range (formerly Size) to replace Min/Max
  • Count to replace MinCount/MaxCount
  • Length to replace MinLength/MaxLength

Feedback is appreciated.

{
public $minMessage = 'This value should be {{ limit }} or more';
public $maxMessage = 'This value should be {{ limit }} or less';
public $invalidMessage = 'This value should be a valid number';
Copy link
Contributor

Choose a reason for hiding this comment

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

this constraint doesnt support the exact number?

8000 Copy link
Contributor Author

Choose a reason for hiding this comment

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

no

@Tobion
Copy link
Contributor
Tobion commented Jul 11, 2012

The choice constraint also cannot handle min = max. Or maybe we don't need these options on choice anymore as we can achieve the same with the new count constraint?!

@beberlei
Copy link
Contributor

Dude, nobody has time to fix the BC breaks you introduce :-)

@TomAdam
Copy link
Contributor
TomAdam commented Jul 12, 2012

The changes to the Size validator yesterday broke my project, and I started rewriting to use MaxLength / MinLength validators today, until I spotted this. It would be good if this PR could have a reasonably high priority (whether or not it is accepted) as it will change how I fix my issues. I suspect a lot of people using the master branch will be in the same situation.

< 8000 p class="ml-1 mb-2 mt-2" data-show-on-error hidden> Sorry, something went wrong.

fabpot added a commit that referenced this pull request Jul 12, 2012
Commits
-------

a92f80b [Validator] Added Length constraint and deprecated MinLength and MaxLength
83a3f75 [Validator] Deprecated the constraints Min and Max in favor of Range
0cdacee [Validator] Removed MinCount and MaxCount and replaced them by the constraint Count
741c147 [Validator] Renamed deprecated Size constraint to Range

Discussion
----------

[Validator] Reintroduced Range constraint and created Count and Length constraints

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

After @Tobion's comment to #4851, this is the next try to streamline the constraints and reduce duplication of logic. The downside of the current MinLength/MaxLength and MinCount/MaxCount pairs is that they cannot output a fitting error message if a value should have an *exact* length/count. So this PR introduces

* Range (formerly Size) to replace Min/Max
* Count to replace MinCount/MaxCount
* Length to replace MinLength/MaxLength

Feedback is appreciated.

---------------------------------------------------------------------------

by Tobion at 2012-07-11T20:40:08Z

The `choice` constraint also cannot handle `min = max`. Or maybe we don't need these options on choice anymore as we can achieve the same with the new `count` constraint?!

---------------------------------------------------------------------------

by beberlei at 2012-07-12T08:59:44Z

Dude, nobody has time to fix the BC breaks you introduce :-)

---------------------------------------------------------------------------

by TomAdam at 2012-07-12T12:38:49Z

The changes to the `Size` validator yesterday broke my project, and I started rewriting to use `MaxLength / MinLength` validators today, until I spotted this. It would be good if this PR could have a reasonably high priority (whether or not it is accepted) as it will change how I fix my issues. I suspect a lot of people using the master branch will be in the same situation.
@fabpot fabpot merged commit a92f80b into symfony:master Jul 12, 2012
@webmozart
Copy link
Contributor Author

@TomAdam The PR is now merged. Sorry for the hassle.

@TomAdam
Copy link
Contributor
TomAdam commented Jul 12, 2012

Much appreciated, and it's no hassle - we chose to work with 2.1, and it's been a great experience.

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.

5 participants
0