Skip to content

[Validator] Pass context to expressions used in When constraints #58512

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

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

KoNekoD
Copy link
Contributor

@KoNekoD KoNekoD commented Oct 9, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #58511
License MIT

I encountered a problem with validation of nested entities and I needed to validate by parent field, if draft true then no validation is needed

@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 7.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

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "7.2" but it seems your PR description refers to branch "7.2 for features / 5.4, 6.4, and 7.1 for bug fixes".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@carsonbot carsonbot changed the title feat(when constraint): pass context and root [Validator] feat(when constraint): pass context and root Oct 9, 2024
@KoNekoD
Copy link
Contributor Author

KoNekoD commented Oct 9, 2024

@xabbuh Looks like it passed the tests(+-). What do you think of this feature?

@nicolas-grekas nicolas-grekas changed the title [Validator] feat(when constraint): pass context and root [Validator] Pass context to expressions used in When contraints Oct 9, 2024
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.

Works for me (ExpressionValidator already has this)
Can you please add a line in the CHANGELOG of the component and a test case?

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.

Can you please rebase to get rid of the merge commit?

@KoNekoD
Copy link
Contributor Author

KoNekoD commented Oct 9, 2024

@nicolas-grekas rebased.

I'm having trouble setting up the tests. CI is too long to do it quickly. Is there any way to set up vendors locally? I'm currently getting an error when installing from a docker container

It is very frustrating that there is no Dockerfile and docker-compose to download dependencies or somehow resolve for it

@KoNekoD KoNekoD force-pushed the when-constraint-improve branch from 4b1eedf to fc9d69b Compare October 9, 2024 15:10
@alexandre-daubois
Copy link
Member

alexandre-daubois commented Oct 9, 2024

You can have a local PHP installation (not in Docker) with apt-get or brew depending on your OS. Then run a composer update at the root of the project. Finally, use ./phpunit path/to/your/Test.php to run it locally.

@KoNekoD
Copy link
Contributor Author

KoNekoD commented Oct 9, 2024

@nicolas-grekas done

@OskarStark OskarStark changed the title [Validator] Pass context to expressions used in When contraints [Validator] Pass context to expressions used in When constraints Oct 9, 2024
@fabpot fabpot force-pushed the when-constraint-improve branch from 4637bf0 to f05ce63 Compare October 10, 2024 05:26
@fabpot
Copy link
Member

fabpot commented Oct 10, 2024

Thank you @KoNekoD.

@fabpot fabpot merged commit 6e9c993 into symfony:7.2 Oct 10, 2024
6 of 10 checks passed
@fabpot fabpot mentioned this pull request Oct 27, 2024
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.

When constraint- Pass context and root to the list of available variables for expression language
7 participants