Closed
Description
https://symfony.com/doc/current/reference/constraints.html groups constraints into categories. But the collection constraints
category looks confusing to me. I don't understand what "collection" means in this title:
Locale
,Language
andCountry
validate the value as belonging to a given set of valuesChoice
does a similar job, but additionally supports being used on an array when using itsmultiple
option (which is not exactly equivalent to using@All(@Choice(multiple=false))
, as it reports only the first invalid value when usingmultiple=true
and does not support Traversable)Count
applies on an array or Countable value (so the "collection" concept here might be the validated value)UniqueEntity
is a class-level constraint validating uniqueness in the DB. I don't see any concept of collection hereCollection
is about applying constraints on specific keys of an array, for cases where you use it as a struct (what Hack calls ashape
), and precisely not when treating the array as a collection
And All
is about applying the same constraints on all items of an iterable (useful to validate collections of items) and is not part of that category.