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
Copy file name to clipboardExpand all lines: Constraints/Length.php
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,7 @@ class Length extends Constraint
41
41
public$min;
42
42
public$charset = 'UTF-8';
43
43
public$normalizer;
44
+
public$allowEmptyString;
44
45
45
46
publicfunction__construct($options = null)
46
47
{
@@ -56,6 +57,13 @@ public function __construct($options = null)
56
57
57
58
parent::__construct($options);
58
59
60
+
if (null === $this->allowEmptyString) {
61
+
$this->allowEmptyString = true;
62
+
if (null !== $this->min) {
63
+
@trigger_error(sprintf('Using the "%s" constraint with the "min" option without setting the "allowEmptyString" one is deprecated and defaults to true. In 5.0, it will become optional and default to false.', self::class), E_USER_DEPRECATED);
64
+
}
65
+
}
66
+
59
67
if (null === $this->min && null === $this->max) {
60
68
thrownewMissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), ['min', 'max']);
* @expectedDeprecation Using the "Symfony\Component\Validator\Constraints\Length" constraint with the "min" option without setting the "allowEmptyString" one is deprecated and defaults to true. In 5.0, it will become optional and default to false.
0 commit comments