-
Symfony version(s) affected6.4 DescriptionWhen validating file uploads using the Current Behavior: if (!\is_scalar($value) && !$value instanceof FileObject && !$value instanceof \Stringable) {
throw new UnexpectedValueException($value, 'string');
} Expected Behavior: How to reproduceCode Example: $builder->add('files', FileType::class, [
'constraints' => [
new File([
'maxSize' => '1024k',
'extensions' => ['jpg','jpeg','png']
], binaryFormat: true)
],
'required' => false,
'multiple' => true
]); Possible SolutionNo response Additional ContextThis appears to be incorrect behavior specifically when validating file inputs with the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you want to add a constraint for each of an array items you need to use |
Beta Was this translation helpful? Give feedback.
If you want to add a constraint for each of an array items you need to use
All
: https://symfony.com/doc/current/reference/constraints/All.html