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

Appearance settings

Commit 16c2086

Browse filesBrowse files
committed
[Constrainst] Expression language allow null
1 parent 4bdc0f4 commit 16c2086
Copy full SHA for 16c2086

File tree

Expand file treeCollapse file tree

2 files changed

+12
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntaxValidator.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public function validate($expression, Constraint $constraint): void
3939
throw new UnexpectedTypeException($constraint, ExpressionLanguageSyntax::class);
4040
}
4141

42+
if (null === $expression) {
43+
return;
44+
}
45+
4246
if (!\is_string($expression)) {
4347
throw new UnexpectedValueException($expression, 'string');
4448
}

‎src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxValidatorTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

1414
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
15+
use Symfony\Component\Validator\Constraints\Email;
1516
use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntax;
1617
use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntaxValidator;
1718
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -65,4 +66,11 @@ public function testExpressionIsNotValid()
6566
->setCode(ExpressionLanguageSyntax::EXPRESSION_LANGUAGE_SYNTAX_ERROR)
6667
->assertRaised();
6768
}
69+
70+
public function testNullIsValid()
71+
{
72+
$this->validator->validate(null, new ExpressionLanguageSyntax());
73+
74+
$this->assertNoViolation();
75+
}
6876
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.