Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd9b195

Browse files
committed
Fix URL validator failure with empty string
Fix validator failure if method `__toString` of passed object return an empty string.
1 parent967c0e4 commitdd9b195

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎src/Symfony/Component/Validator/Constraints/UrlValidator.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function validate($value, Constraint $constraint)
4848
thrownewUnexpectedTypeException($constraint,__NAMESPACE__.'\Url');
4949
}
5050

51-
if (null ===$value ||'' ===$value) {
51+
if (null ===$value) {
5252
return;
5353
}
5454

@@ -57,6 +57,10 @@ public function validate($value, Constraint $constraint)
5757
}
5858

5959
$value = (string)$value;
60+
if ('' ===$value) {
61+
return;
62+
}
63+
6064
$pattern =sprintf(static::PATTERN,implode('|',$constraint->protocols));
6165

6266
if (!preg_match($pattern,$value)) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp