Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
e9a2a0b tobfe542dComparesrc/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedDec 13, 2023
Let's add |
710571f toecb57d7CompareOskarStark commentedDec 14, 2023
Please update the PR title + description to reflect the additional option, thanks |
list type toType constraintlist andassociative_array types toType constraintecb57d7 to5ab4068Comparefabpot commentedDec 20, 2023
Thank you@hermann8u. |
ro0NL commentedDec 20, 2023
in php any array is associative ;) |
ro0NL commentedDec 21, 2023
@hermann8u i fail to see what usecase would allow for [1 => some], but not [0 => some] |
hermann8u commentedDec 21, 2023
@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. |
hermann8u commentedDec 22, 2023
@ro0NL Ok I got your point finally. What you mean is that list are also associative_array? |
Uh oh!
There was an error while loading.Please reload this page.
Hello!
This PR aims to add support for
listtype in theTypeconstraint.This is done by using thenew PHP 8.1 function
array_is_list, after checking that the value is an array withis_arrayfunction.Here is an example of use:
I consider doing an other PR to add
associative_arraytype 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 support
associative_arraytype aswell :An
associative_arrayis an array that is not a list. Moreover, this means that an empty array will not be considered as anassociative_array.Best regards