I have a very simple array of strings being stored in a database and provided via an API.
Using Symfony's form types I'm adding validation for various bits of data.
I've hit a wall with a CollectionType that is essentially an array of strings, for example:
['key', 'words', 'are', 'the', 'best']
With the form code:
->add('keywords', CollectionType::class, [
'allow_add' => true,
'constraints' => [
new Count(['min' => 1]),
new NotBlank(['allowNull' => false])
]
])
This is allowing the following to pass the constraints:
[null] and ['']
If I can figure out what I'm doing wrong I'd like to add Regex validation to each element as well.