Permalink
Browse files

[Validator] Fixed UrlValidator to accept empty strings (closes #9297)

  • Loading branch information...
Gustavo Falco authored and fabpot committed Nov 27, 2010
1 parent f73b6b4 commit af291bb0f1c9032adaa96790829cbe04077a8234
@@ -30,7 +30,7 @@ class UrlValidator extends ConstraintValidator
public function isValid($value, Constraint $constraint)
{
- if ($value === null) {
+ if ($value === null || $value === '') {
return true;
}
@@ -19,6 +19,11 @@ public function testNullIsValid()
$this->assertTrue($this->validator->isValid(null, new Url()));
}
+ public function testEmptyStringIsValid()
+ {
+ $this->assertTrue($this->validator->isValid('', new Url()));
+ }
+
public function testExpectsStringCompatibleType()
{
$this->setExpectedException('Symfony\Component\Validator\Exception\UnexpectedTypeException');

0 comments on commit af291bb

Please sign in to comment.