Fixed the null value exception case.
This commit is contained in:
parent
c927c481aa
commit
56f24d08c9
@ -26,6 +26,10 @@ class ValidValidator extends ConstraintValidator
|
|||||||
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Valid');
|
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Valid');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->context
|
$this->context
|
||||||
->getValidator()
|
->getValidator()
|
||||||
->inContext($this->context)
|
->inContext($this->context)
|
||||||
|
@ -20,6 +20,18 @@ class ValidValidatorTest extends TestCase
|
|||||||
$this->assertSame('fooBar.fooBarBaz.foo', $violations->get(0)->getPropertyPath());
|
$this->assertSame('fooBar.fooBarBaz.foo', $violations->get(0)->getPropertyPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNullValues()
|
||||||
|
{
|
||||||
|
$validatorBuilder = new ValidatorBuilder();
|
||||||
|
$validator = $validatorBuilder->enableAnnotationMapping()->getValidator();
|
||||||
|
|
||||||
|
$foo = new Foo();
|
||||||
|
$foo->fooBar = null;
|
||||||
|
$violations = $validator->validate($foo, null, array('nested'));
|
||||||
|
|
||||||
|
$this->assertCount(0, $violations);
|
||||||
|
}
|
||||||
|
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
return new ValidValidator();
|
return new ValidValidator();
|
||||||
|
Reference in New Issue
Block a user