Closed
Description
Hello,
When using Validator 2.5 to validate an array of scalars, the propertyPath
of the returned violations has really strange values.
Consider the following script:
<?php
require 'vendor/autoload.php';
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Validation;
$constraints = array(
'foo' => array(
new Constraints\NotBlank(),
new Constraints\Date()
),
'bar' => new Constraints\NotBlank()
);
$collectionConstraint = new Constraints\Collection(array('fields' => $constraints));
$validator = Validation::createValidatorBuilder()
->setApiVersion(Validation::API_VERSION_2_5)
->getValidator();
$value = array(
'foo' => 'bar'
);
$violations = $validator->validate($value, $collectionConstraint);
foreach ($violations as $violation) {
var_dump($violation->getPropertyPath());
}
Output:
string(11) "[foo].[foo]"
string(17) "[foo].[foo].[bar]"
If I set Validation::API_VERSION_2_4
and call the old validateValue
method, it outputs:
string(5) "[foo]"
string(5) "[bar]"
Is this something expected ?