Skip to content

[Validator] improve strict option value deprecation #22826

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions UPGRADE-3.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
UPGRADE FROM 3.3 to 3.4
=======================

Validator
---------

* not setting the `strict` option of the `Choice` constraint to `true` is
deprecated and will throw an exception in Symfony 4.0
3 changes: 3 additions & 0 deletions UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@ TwigBridge
Validator
---------

* The default value of the `strict` option of the `Choice` constraint was changed
to `true`. Using any other value will throw an exception.

* The `DateTimeValidator::PATTERN` constant was removed.

* `Tests\Constraints\AbstractConstraintValidatorTest` has been removed in
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/Validator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGELOG
=========

3.4.0
-----

* not setting the `strict` option of the `Choice` constraint to `true` is
deprecated and will throw an exception in Symfony 4.0

3.3.0
-----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function validate($value, Constraint $constraint)
$choices = $constraint->choices;
}

if (false === $constraint->strict) {
@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);
if (true !== $constraint->strict) {
@trigger_error('Not setting the strict option of the Choice constraint to true is deprecated since version 3.4 and will throw an exception in 4.0.', E_USER_DEPRECATED);
}

if ($constraint->multiple) {
Expand Down