Closed
Description
Symfony version(s) affected: 4.1.3
Description
When passing constraint to validate
method I've got violations from annotation constrains.
How to reproduce
https://github.com/BoShurik/symfony-validator-issue
class Foo
{
/**
* @var Bar[]
*
* @Assert\Valid()
*/
public $bars;
public function __construct()
{
$this->bars = [
new Bar(),
new Bar(),
];
}
}
$violations = $this->validator->validate($model->bars, new Count([
'min' => 3,
'max' => 3,
]));
/** @var ConstraintViolationInterface $violation */
foreach ($violations as $violation) {
dump(sprintf('%s: %s', $violation->getPropertyPath(), $violation->getMessage()));
}
/*
Got:
": This collection should contain exactly 3 elements."
"[0].name: This value should not be blank." <- not expected
"[1].name: This value should not be blank." <- not expected
*/