8000 [Validator] Deprecated comparison constraints by webmozart · Pull Request #12389 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Deprecated comparison constraints #12389

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

Closed
wants to merge 1 commit into from
Closed
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
37 changes: 37 additions & 0 deletions UPGRADE-2.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,43 @@ Validator
```
value == null or (YOUR_EXPRESSION)
```

* The basic comparison constraints were deprecated and will be removed in
Symfony 3.0:

* `AbstractComparison` and `AbstractComparisonValidator`
* `Blank` and `BlankValidator`
* `EqualTo` and `EqualToValidator`
* `False` and `FalseValidator`
* `GreaterThan` and `GreaterThanValidator`
* `GreaterThanOrEqual` and `GreaterThanOrEqualValidator`
* `IdenticalTo` and `IdenticalToValidator`
* `LessThan` and `LessThanValidator`
* `LessThanOrEqual` and `LessThanOrEqualValidator`
* `NotEqualTo` and `NotEqualToValidator`
* `NotIdenticalTo` and `NotIdenticalToValidator`
* `Null` and `NullValidator`
* `True` and `TrueValidator`

You should use the `Expression` constraint instead.

Before:

```php
/**
* @GreaterThan(0, message="Please enter a positive number.")
*/
private $age;
```

After:

```php
/**
* @Expression("value > 0", message="Please enter a positive number.")
*/
private $age;
```

Security
--------
Expand Down
13 changes: 13 additions & 0 deletions src/Symfony/Component/Validator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ CHANGELOG
* [BC BREAK] added `Mapping\MetadataInterface::getConstraints()`
* added generic "payload" option to all constraints for attaching domain-specific data
* [BC BREAK] added `ConstraintViolationBuilderInterface::setCause()`
* deprecated `AbstractComparison` and `AbstractComparisonValidator`
* deprecated `Blank` and `BlankValidator`
* deprecated `EqualTo` and `EqualToValidator`
* deprecated `False` and `FalseValidator`
* deprecated `GreaterThan` and `GreaterThanValidator`
* deprecated `GreaterThanOrEqual` and `GreaterThanOrEqualValidator`
* deprecated `IdenticalTo` and `IdenticalToValidator`
* deprecated `LessThan` and `LessThanValidator`
* deprecated `LessThanOrEqual` and `LessThanOrEqualValidator`
* deprecated `NotEqualTo` and `NotEqualToValidator`
* deprecated `NotIdenticalTo` and `NotIdenticalToValidator`
* deprecated `Null` and `NullValidator`
* deprecated `True` and `TrueValidator`

2.5.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
* Used for the comparison of values.
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
abstract class AbstractComparison extends Constraint
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*
* @author Daniel Holmes <daniel@danielholmes.org>
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
abstract class AbstractComparisonValidator extends ConstraintValidator
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/Blank.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class Blank extends Constraint
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class BlankValidator extends ConstraintValidator
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/EqualTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class EqualTo extends AbstractComparison
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Validates values are equal (==).
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class EqualToValidator extends AbstractComparisonValidator
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/False.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class False extends Constraint
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class FalseValidator extends ConstraintValidator
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/GreaterThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class GreaterThan extends AbstractComparison
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class GreaterThanOrEqual extends AbstractComparison
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Validates values are greater than or equal to the previous (>=).
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class GreaterThanOrEqualValidator extends AbstractComparisonValidator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Validates values are greater than the previous (>).
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class GreaterThanValidator extends AbstractComparisonValidator
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/IdenticalTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class IdenticalTo extends AbstractComparison
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Validates values are identical (===).
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class IdenticalToValidator extends AbstractComparisonValidator
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/LessThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class LessThan extends AbstractComparison
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class LessThanOrEqual extends AbstractComparison
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Validates values are less than or equal to the previous (<=).
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class LessThanOrEqualValidator extends AbstractComparisonValidator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Validates values are less than the previous (<).
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class LessThanValidator extends AbstractComparisonValidator
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/NotEqualTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class NotEqualTo extends AbstractComparison
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Validates values are all unequal (!=).
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class NotEqualToValidator extends AbstractComparisonValidator
{
Expand Down
10000
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class NotIdenticalTo extends AbstractComparison
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Validates values aren't identical (!==).
*
* @author Daniel Holmes <daniel@danielholmes.org>
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class NotIdenticalToValidator extends AbstractComparisonValidator
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/Null.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class Null extends Constraint
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/NullValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @ 10225 api
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class NullValidator extends ConstraintValidator
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/True.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class True extends Constraint
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/TrueValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @api
*
* @deprecated Deprecated as of Symfony 2.6, to be removed in version 3.0.
* Use {@link Expression} instead.
*/
class TrueValidator extends ConstraintValidator
{
Expand Down
0