-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Add is_valid function to Expression constraint #47153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Validator] Add is_valid function to Expression constraint #47153
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
src/Symfony/Component/Validator/Constraints/ExpressionValidator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Constraints/ExpressionLanguageProvider.php
Outdated
Show resolved
Hide resolved
fc723f8
to
4c99064
Compare
4c99064
to
5dad241
Compare
src/Symfony/Component/Validator/Constraints/ExpressionLanguageProvider.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php
Outdated
Show resolved
Hide resolved
5dad241
to
ea6879a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks, here is some final nitpicking
src/Symfony/Component/Validator/Constraints/ExpressionValidator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageProviderTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageProviderTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageProviderTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageProviderTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php
Outdated
Show resolved
Hide resolved
|
||
$this->validator->validate($object, $constraint); | ||
|
||
$this->assertCount(2, $this->context->getViolations()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be $this->assertCount(1, $this->context->getViolations());
? Or put the other way: Where is the second violation coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one violation from is_valid, second from expression itself
@@ -27,6 +27,7 @@ class ExpressionValidator extends ConstraintValidator | |||
public function __construct(ExpressionLanguage $expressionLanguage = null) | |||
{ | |||
$this->expressionLanguage = $expressionLanguage; | |||
$this->expressionLanguage?->registerProvider(new ExpressionLanguageProvider()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't mutate the expression language we receive in the constructor, it would lead to unexpected behavior if the provided expression language is used elsewhere.
7f3acc7
to
a45c2af
Compare
Continued in #50438 |
Add
is_valid
function to theExpression
constraint, api the same asValidatorInterface::validate