-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Deprecated the Size constraint in favor of MinCount and MaxCount #4851
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
Conversation
@@ -1136,6 +1136,26 @@ | |||
private $recursiveCollection; | |||
``` | |||
|
|||
* The `Size` constraint was deprecated and will be removed in Symfony 2.1. You should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be 2.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Commits ------- 0be602d [Validator] Deprecated the Size constraint d661837 [Validator] Reverted the changes done to the Size constraint in 3a5e84f d84b689 [Validator] Added the constraints MinCount and MaxCount 1a732e4 [Validator] Removed the Range constraint as it duplicates functionality given in Min and Max Discussion ---------- [Validator] Deprecated the Size constraint in favor of MinCount and MaxCount Bug fix: no Feature addition: yes Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: - Todo: - This PR cleans up with the current ambiguity between * Min * Max * MinLength * MaxLength * Range * Size in the following ways: * The Range constraint was removed again as it can be completely replaced by Min and Max. * The Size constraint was reverted to it's 2.0 feature set and deprecated. * The constraints MinCount and MaxCount were added to make up for the functionality that was added to Size.
I thought you would deprecate the other way round because it's more flexible. So e.g. Range in favor of Min and Max. Say my collection should contain excatly 8 elements so constraint MinCount(8) and MaxCount(8). |
Good points. I created a new PR that is referenced above. |
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.
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
This PR cleans up with the current ambiguity between
in the following ways: