Skip to content

Commit 1c73339

Browse files
committed
minor #19320 [Validator] Add list and associative_array types to Type constraint (alexandre-daubois)
This PR was merged into the 7.1 branch. Discussion ---------- [Validator] Add `list` and `associative_array` types to Type constraint Fix #19319 Commits ------- e12c974 [Validator] Add `list` and `associative_array` types to Type constraint
2 parents c7ac483 + e12c974 commit 1c73339

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

reference/constraints/Type.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ PHP class/interface or a valid PHP datatype (checked by PHP's ``is_()`` function
190190
* :phpfunction:`resource <is_resource>`
191191
* :phpfunction:`null <is_null>`
192192

193+
If you're dealing with arrays, you can use the following types in the constraint:
194+
195+
* ``list`` which uses :phpfunction:`array_is_list <array_is_list>` internally
196+
* ``associative_array`` which is true for any **non-empty** array that is not a list
197+
193198
Also, you can use ``ctype_*()`` functions from corresponding
194199
`built-in PHP extension`_. Consider `a list of ctype functions`_:
195200

@@ -208,6 +213,11 @@ Also, you can use ``ctype_*()`` functions from corresponding
208213
Make sure that the proper :phpfunction:`locale <setlocale>` is set before
209214
using one of these.
210215

216+
.. versionadded:: 7.1
217+
218+
The ``list`` and ``associative_array`` types were introduced in Symfony
219+
7.1.
220+
211221
Finally, you can use aggregated functions:
212222

213223
* ``number``: ``is_int || is_float && !is_nan``

0 commit comments

Comments
 (0)