Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Validator] Validate all groups when special group name* is specified invalidate() method#50679

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dwgebler wants to merge5 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromdwgebler:feature/validator-all-groups

Conversation

dwgebler
Copy link

@dwgeblerdwgebler commentedJun 15, 2023
edited
Loading

QA
Branch?6.4
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#49932
LicenseMIT
Doc PRsymfony/symfony-docs#18420

Adds a special group name* which can be used with the validator to validate all groups on the object being validated. This is comparable to how the group name* can be used onSerializer component, ref.https://symfony.com/doc/current/components/serializer.html#attributes-groups

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.4 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

@dwgeblerdwgeblerforce-pushed thefeature/validator-all-groups branch frome3de840 toa279c56CompareJune 15, 2023 22:50
@xabbuh
Copy link
Member

I am afraid that doing this change would be a BC break in case someone actually uses this "special" group.

@dwgebler
Copy link
Author

From the issue, im curious about your usecase

or put different, IMHO context should tell you with groups to validate, isnt it

there can also be contradictions between groups IIUC

I had a case of a large object graph (so object to be validated had several other objects withValid constraint on them, which all also needed to be validated) and there were about 25 groups in total. So to validate the entire object every possible group on the object and every object it contained had to be specified.

It very much seems like there should be an easy way to validate an entire object regardless of group metadata; it doesn't strike me as a particularly niche case.

@dwgebler
Copy link
Author

I am afraid that doing this change would be a BC break in case someone actually uses this "special" group.

I'm happy to change the approach if necessary (open to discussion on that), or target 7.0.

@dwgebler
Copy link
Author

i guess it could work in some cases, till it doesnt, eg.:

#[Blank(groups: ['a'])]#[NotBlank(groups: ['b'])]public $a;

but maybe that's more of a user concern 👍

Yeah I mean you'll get a violation there, but that's expected behaviour because the constraints can't both be valid. If you had contradicting constraints, it'd be a solid indicator validating everything at once isn't your use case.

@param string|GroupSequence|array<string|GroupSequence>|null $groups

maybe supporttrue here?

Possibly. I'd be interested to get more feedback on this and other options from other maintainers before I update the PR with any new approach.

@OskarStarkOskarStark changed the titleValidate all groups when special group name "*" is specified in validate()Validate all groups when special group name* is specified invalidate() methodJun 19, 2023
@carsonbotcarsonbot changed the titleValidate all groups when special group name* is specified invalidate() method[Validator] Validate all groups when special group name* is specified invalidate() methodJun 19, 2023
@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@dwgebler
Copy link
Author

@nicolas-grekas@fabpot had this PR open for about 18 months. I still believe it's a valuable feature to provide a way to validate all constraint groups on an object. If there are concerns still about the validation group name* causing a BC-break, can we either target next major version or re-open a conversation about how else this could be solved?

@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

Include option in validator to validate all groups
6 participants
@dwgebler@carsonbot@xabbuh@fabpot@nicolas-grekas@OskarStark

[8]ページ先頭

©2009-2025 Movatter.jp