[Validator] Add object handling of invalid constraints in Composite
This commit is contained in:
parent
f9b64a206b
commit
4bd2c22871
@ -67,6 +67,10 @@ abstract class Composite extends Constraint
|
|||||||
|
|
||||||
foreach ($nestedConstraints as $constraint) {
|
foreach ($nestedConstraints as $constraint) {
|
||||||
if (!$constraint instanceof Constraint) {
|
if (!$constraint instanceof Constraint) {
|
||||||
|
if (is_object($constraint)) {
|
||||||
|
$constraint = get_class($constraint);
|
||||||
|
}
|
||||||
|
|
||||||
throw new ConstraintDefinitionException(sprintf('The value %s is not an instance of Constraint in constraint %s', $constraint, get_class($this)));
|
throw new ConstraintDefinitionException(sprintf('The value %s is not an instance of Constraint in constraint %s', $constraint, get_class($this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +125,17 @@ class CompositeTest extends TestCase
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||||
|
*/
|
||||||
|
public function testFailIfNoConstraintObject()
|
||||||
|
{
|
||||||
|
new ConcreteComposite(array(
|
||||||
|
new NotNull(array('groups' => 'Default')),
|
||||||
|
new \ArrayObject(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user