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] Avoid TypeError and improve DX when null groups#49137

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
alamirault wants to merge2 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromalamirault:hotfix/improve-dx-null-groups-validator

Conversation

alamirault
Copy link
Contributor

@alamiraultalamirault commentedJan 27, 2023
edited by nicolas-grekas
Loading

QA
Branch?6.3
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix #...
LicenseMIT
Doc PRsymfony/symfony-docs#...

Improve DX when we pass null value in array of groups

$this->validate($entity,null, ['Group 1',null])

Before this PR
TypeError: Symfony\Component\Validator\Context\ExecutionContext::isGroupValidated(): Argument #2 ($groupHash) must be of type string, null given,

@xabbuh
Copy link
Member

There are probably more places inside theRecursiveContextualValidator where this could be done. What about doing this innormalizeGroups() instead?

@alamirault
Copy link
ContributorAuthor

You're right , I updated PR

@alamirault
Copy link
ContributorAuthor

@xabbuh Are you ok with the new version ?

}

return [$groups];
if (\in_array(null, $groups, true)) {
throw new ValidatorException('Value in array of validation groups cannot be null.');

Choose a reason for hiding this comment

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

Should be an InvalidArgumentException I suppose?
What about other types that are neither strings nor GroupSequence?
Also, since this is an improvement, it should target 6.3.

@nicolas-grekasnicolas-grekas modified the milestones:5.4,6.3Apr 18, 2023
@nicolas-grekasnicolas-grekas changed the base branch from5.4 to6.3April 18, 2023 08:58
@nicolas-grekasnicolas-grekas modified the milestones:6.3,6.4May 23, 2023
@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@xabbuhxabbuhAwaiting requested review from xabbuh

Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

4 participants
@alamirault@xabbuh@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp