8000 [Validator] Add is_valid function to Expression constraint by verdet23 · Pull Request #47153 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed

Conversation

verdet23
Copy link
Contributor
@verdet23 verdet23 commented Aug 2, 2022
Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #11940
License MIT
Doc PR TODO

Add is_valid function to the Expression constraint, api the same as ValidatorInterface::validate

@carsonbot
Copy link

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:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.2 branch.

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!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@verdet23 verdet23 force-pushed the feature/validator-expression-is_valid branch from fc723f8 to 4c99064 Compare August 4, 2022 11:51
@verdet23 verdet23 requested a review from xabbuh August 4, 2022 11:52
@verdet23 verdet23 force-pushed the feature/validator-expression-is_valid branch from 4c99064 to 5dad241 Compare August 8, 2022 11:01
Copy link
Member
@nicolas-grekas nicolas-grekas left a 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


$this->validator->validate($object, $constraint);

$this->assertCount(2, $this->context->getViolations());
Copy link
Member

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?

Copy link
Contributor Author

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());
Copy link
Contributor

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.

@verdet23 verdet23 force-pushed the feature/validator-expression-is_valid branch from 7f3acc7 to a45c2af Compare August 11, 2022 11:18
@nicolas-grekas nicolas-grekas modified the milestones: 6.2, 6.3 Nov 5, 2022
@nicolas-grekas nicolas-grekas removed this from the 6.3 milestone May 23, 2023
@nicolas-grekas
Copy link
Member

Continued in #50438

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Validator] Validate from within Expression
5 participants
0