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

[Validator] Allow Sequentially constraints on classes + target guards #35815

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
Feb 25, 2020
Merged

[Validator] Allow Sequentially constraints on classes + target guards #35815

merged 1 commit into from
Feb 25, 2020

Conversation

ogizanagi
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets N/A
License MIT
Doc PR todo in symfony/symfony-docs#13206 if not merged yet

There is no reason to limit this constraint to properties, so let's add classes as targets.

Additionally, let's ensure embedded constraints matches allowed targets too.

@@ -178,6 +180,14 @@ public function addConstraint(Constraint $constraint)
throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on classes.', \get_class($constraint)));
}

if ($constraint instanceof Sequentially || $constraint instanceof Compound) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All could probably be added to this list, but could it lead to a BC break somehow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All could probably be added to this list

Why? It does not allow classes already thanks to the if before 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong path. I meant in MemberMetadata 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what about a check against Composite instead? It may be needed for both then, and even target 3.4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, let's consider this a bug fix. I'll move the second commit to another PR for 3.4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #35843

Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nicolas-grekas
Copy link
Member

Thank you @ogizanagi.

@nicolas-grekas nicolas-grekas merged commit 7b89d1b into symfony:master Feb 25, 2020
@ogizanagi ogizanagi deleted the validator-sequentially-on-classes branch February 25, 2020 15:27
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
@fabpot fabpot mentioned this pull request May 5, 2020
fabpot added a commit that referenced this pull request Aug 12, 2020
…ints (ogizanagi)

This PR was merged into the 3.4 branch.

Discussion
----------

[Validator] Add target guards for Composite nested constraints

| Q             | A
| ------------- | ---
| Branch?       | 3.4 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #35815 (review) <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | N/A

Commits
-------

a08ddf7 [Validator] Add target guards for Composite nested constraints
symfony-splitter pushed a commit to symfony/validator that referenced this pull request Aug 12, 2020
…ints (ogizanagi)

This PR was merged into the 3.4 branch.

Discussion
----------

[Validator] Add target guards for Composite nested constraints

| Q             | A
| ------------- | ---
| Branch?       | 3.4 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix symfony/symfony#35815 (review) <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | N/A

Commits
-------

a08ddf7636 [Validator] Add target guards for Composite nested constraints
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.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.