From 1bdd1e0565feedc8cbf48ab8dda6e4ca9a952d75 Mon Sep 17 00:00:00 2001 From: Ivan Kurnosov Date: Sat, 10 Mar 2018 11:11:54 +1300 Subject: [PATCH] AllValidator should not throw when not traversable is passed --- .../Component/Validator/Constraints/AllValidator.php | 2 +- .../Validator/Tests/Constraints/AllValidatorTest.php | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/AllValidator.php b/src/Symfony/Component/Validator/Constraints/AllValidator.php index a5eb32bbd9796..fcbd5b6de0de0 100644 --- a/src/Symfony/Component/Validator/Constraints/AllValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AllValidator.php @@ -34,7 +34,7 @@ public function validate($value, Constraint $constraint) } if (!is_array($value) && !$value instanceof \Traversable) { - throw new UnexpectedTypeException($value, 'array or Traversable'); + return; } $context = $this->context; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php index 2792dc4014a73..8ac30a718188b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php @@ -31,12 +31,9 @@ public function testNullIsValid() $this->assertNoViolation(); } - /** - * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException - */ - public function testThrowsExceptionIfNotTraversable() + public function testNotTraversableIsValid() { - $this->validator->validate('foo.barbar', new All(new Range(array('min' => 4)))); + $this->assertNull($this->validator->validate('foo.barbar', new All(new Range(array('min' => 4))))); } /** pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy