You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #19257 [Validator][Choice] Make strict the default option for choice validation (peterrehm)
This PR was squashed before being merged into the 3.2-dev branch (closes #19257).
Discussion
----------
[Validator][Choice] Make strict the default option for choice validation
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | #18973
| License | MIT
| Doc PR | -
This is just the WIP as there are two options.
1. Just change default which would only possible to introduce in 4.x or in 3.2 if this BC break is considered as acceptable
2. Add a new option e.g. `strictComparison` which defaults to true in 4.x and deprecate the usage of the strict option for 3.2.
3. Just deprecate strict = false and remove the option but I would be against that as we remove flexibility which might be wanted.
As per discussion I went ahead with option 3. We can then still decide if we want to remove the option entirely or eventually reenable setting strict to false in a later release.
Commits
-------
177c513 [Validator][Choice] Make strict the default option for choice validation
Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/ChoiceValidator.php
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,10 @@ public function validate($value, Constraint $constraint)
57
57
$choices = $constraint->choices;
58
58
}
59
59
60
+
if (false === $constraint->strict) {
61
+
@trigger_error('Setting the strict option of the Choice constraint to false is deprecated since version 3.2 and will be removed in 4.0.', E_USER_DEPRECATED);
62
+
}
63
+
60
64
if ($constraint->multiple) {
61
65
foreach ($valueas$_value) {
62
66
if (!in_array($_value, $choices, $constraint->strict)) {
0 commit comments