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] Addlist andassociative_array types toType constraint#52954

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

Merged
fabpot merged 1 commit intosymfony:7.1fromhermann8u:validator/type/list
Dec 20, 2023

Conversation

@hermann8u
Copy link
Contributor

@hermann8uhermann8u commentedDec 8, 2023
edited
Loading

QA
Branch?7.1
Bug fix?no
New feature?yes
Deprecations?no
Issues-
LicenseMIT

Hello!

This PR aims to add support forlist type in theTypeconstraint.

This is done by using thenew PHP 8.1 functionarray_is_list, after checking that the value is an array withis_array function.

Here is an example of use:

#[Assert\Type('list')]private$value;

I consider doing an other PR to addassociative_array type aswell. Or if you think it's ok, I can also add it in an other commit on this one.

--- UPDATE

After fabpot comment, I added an other commit to supportassociative_array type aswell :

#[Assert\Type('associative_array')]private$value;

Anassociative_array is an array that is not a list. Moreover, this means that an empty array will not be considered as anassociative_array.

Best regards

@fabpot
Copy link
Member

Let's addassociative_array support in the same PR as this is closely related.

hermann8u reacted with thumbs up emoji

@hermann8uhermann8uforce-pushed thevalidator/type/list branch 2 times, most recently from710571f toecb57d7CompareDecember 13, 2023 10:25
@OskarStark
Copy link
Contributor

Please update the PR title + description to reflect the additional option, thanks

hermann8u reacted with thumbs up emoji

@hermann8uhermann8u changed the title[Validator] Addlist type toType constraint[Validator] Addlist andassociative_array types toType constraintDec 14, 2023
@fabpot
Copy link
Member

Thank you@hermann8u.

hermann8u reacted with hooray emoji

@ro0NL
Copy link
Contributor

in php any array is associative ;)

@ro0NL
Copy link
Contributor

@hermann8u i fail to see what usecase would allow for [1 => some], but not [0 => some]

@hermann8u
Copy link
ContributorAuthor

@ro0NL I don't know, maybe when 1 is an id for example? I'm currently working on an other PR that add a constraint to validate array keys that could be used in association with this one.

@hermann8uhermann8u deleted the validator/type/list branchDecember 21, 2023 16:51
@hermann8u
Copy link
ContributorAuthor

@ro0NL Ok I got your point finally. What you mean is that list are also associative_array?

ro0NL reacted with thumbs up emoji

@fabpotfabpot mentioned this pull requestMay 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@derrabusderrabusderrabus left review comments

@fabpotfabpotfabpot approved these changes

@welcoMatticwelcoMatticwelcoMattic approved these changes

@OskarStarkOskarStarkOskarStark approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

7.1

Development

Successfully merging this pull request may close these issues.

7 participants

@hermann8u@fabpot@OskarStark@ro0NL@welcoMattic@derrabus@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp