diff --git a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php index 684731feec..f7f12f0808 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php @@ -75,6 +75,12 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest $this->assertCount(1, $violations); } + public function testValidateWithEmptyArrayAsConstraint() + { + $violations = $this->validator->validate('value', array()); + $this->assertCount(0, $violations); + } + public function testGroupSequenceAbortsAfterFailedGroup() { $entity = new Entity(); diff --git a/src/Symfony/Component/Validator/Validator/LegacyValidator.php b/src/Symfony/Component/Validator/Validator/LegacyValidator.php index ce3501f216..d18c7c5c7d 100644 --- a/src/Symfony/Component/Validator/Validator/LegacyValidator.php +++ b/src/Symfony/Component/Validator/Validator/LegacyValidator.php @@ -69,7 +69,7 @@ class LegacyValidator extends RecursiveValidator implements LegacyValidatorInter private static function testConstraints($constraints) { - return null === $constraints || $constraints instanceof Constraint || (is_array($constraints) && current($constraints) instanceof Constraint); + return null === $constraints || $constraints instanceof Constraint || (is_array($constraints) && (0 === count($constraints) || current($constraints) instanceof Constraint)); } private static function testGroups($groups)