Explorar o código

[Validator] restricted the True and False validator accepted values (the notion of True/False in PHP alone is too large)

Fabien Potencier %!s(int64=14) %!d(string=hai) anos
pai
achega
482492625d

+ 5 - 5
src/Symfony/Component/Validator/Constraints/FalseValidator.php

@@ -22,12 +22,12 @@ class FalseValidator extends ConstraintValidator
             return true;
         }
 
-        if ($value) {
-            $this->setMessage($constraint->message);
-
-            return false;
+        if (false === $value || 0 === $value || '0' === $value) {
+            return true;
         }
 
-        return true;
+        $this->setMessage($constraint->message);
+
+        return false;
     }
 }

+ 5 - 5
src/Symfony/Component/Validator/Constraints/TrueValidator.php

@@ -22,12 +22,12 @@ class TrueValidator extends ConstraintValidator
             return true;
         }
 
-        if (!$value) {
-            $this->setMessage($constraint->message);
-
-            return false;
+        if (true === $value || 1 === $value || '1' === $value) {
+            return true;
         }
 
-        return true;
+        $this->setMessage($constraint->message);
+
+        return false;
     }
 }