<p dir="auto">I have a form some fields are not validated based on the validation groups. The validation works as expected but the error message is always added to the wrong field. It seems to just use which ever property is last in the validation.yml file.</p>
<p dir="auto">I believe my use case is valid. It worked fine in 2.4 but when testing 2.5 BETA2 there were test failures. Also seems to be an issue with the master branch.</p>
<p dir="auto">I found it easiest to reproduce the issue using a system test. This can be found in the following repository: <a href="https://github.com/tompedals/symfony-form-test">https://github.com/tompedals/symfony-form-test</a></p>
<p dir="auto">Model: <a href="https://github.com/tompedals/symfony-form-test/blob/master/src/Test/FormTestBundle/Model/Attachment.php">https://github.com/tompedals/symfony-form-test/blob/master/src/Test/FormTestBundle/Model/Attachment.php</a></p>
<p dir="auto">Form: <a href="https://github.com/tompedals/symfony-form-test/blob/master/src/Test/FormTestBundle/Form/AttachmentType.php">https://github.com/tompedals/symfony-form-test/blob/master/src/Test/FormTestBundle/Form/AttachmentType.php</a></p>
<p dir="auto">Validation mapping: <a href="https://github.com/tompedals/symfony-form-test/blob/master/src/Test/FormTestBundle/Resources/config/validation.yml">https://github.com/tompedals/symfony-form-test/blob/master/src/Test/FormTestBundle/Resources/config/validation.yml</a></p>
<p dir="auto">Test: <a href="https://github.com/tompedals/symfony-form-test/blob/master/src/Test/FormTestBundle/Tests/Form/AttachmentTypeTest.php">https://github.com/tompedals/symfony-form-test/blob/master/src/Test/FormTestBundle/Tests/Form/AttachmentTypeTest.php</a></p>
<p dir="auto">Use <code class="notranslate">phpunit -c app</code> to run the tests.</p>
<p dir="auto">Hello,</p>
<p dir="auto">When using Validator 2.5 to validate an array of scalars, the <code class="notranslate">propertyPath</code> of the returned violations has really strange values.</p>
<p dir="auto">Consider the following script:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;?php

require 'vendor/autoload.php';

use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Validation;

$constraints = array(
    'foo' =&gt; array(
        new Constraints\NotBlank(),
        new Constraints\Date()
    ),
    'bar' =&gt; new Constraints\NotBlank()
);

$collectionConstraint = new Constraints\Collection(array('fields' =&gt; $constraints));

$validator = Validation::createValidatorBuilder()
    -&gt;setApiVersion(Validation::API_VERSION_2_5)
    -&gt;getValidator();

$value = array(
    'foo' =&gt; 'bar'
);

$violations = $validator-&gt;validate($value, $collectionConstraint);

foreach ($violations as $violation) {
    var_dump($violation-&gt;getPropertyPath());
}"><pre class="notranslate"><code class="notranslate">&lt;?php

require 'vendor/autoload.php';

use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Validation;

$constraints = array(
    'foo' =&gt; array(
        new Constraints\NotBlank(),
        new Constraints\Date()
    ),
    'bar' =&gt; new Constraints\NotBlank()
);

$collectionConstraint = new Constraints\Collection(array('fields' =&gt; $constraints));

$validator = Validation::createValidatorBuilder()
    -&gt;setApiVersion(Validation::API_VERSION_2_5)
    -&gt;getValidator();

$value = array(
    'foo' =&gt; 'bar'
);

$violations = $validator-&gt;validate($value, $collectionConstraint);

foreach ($violations as $violation) {
    var_dump($violation-&gt;getPropertyPath());
}
</code></pre></div>
<p dir="auto">Output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="string(11) &quot;[foo].[foo]&quot;
string(17) &quot;[foo].[foo].[bar]&quot;"><pre class="notranslate"><code class="notranslate">string(11) "[foo].[foo]"
string(17) "[foo].[foo].[bar]"
</code></pre></div>
<p dir="auto">If I set <code class="notranslate">Validation::API_VERSION_2_4</code> and call the old <code class="notranslate">validateValue</code> method, it outputs:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="string(5) &quot;[foo]&quot;
string(5) &quot;[bar]&quot;"><pre class="notranslate"><code class="notranslate">string(5) "[foo]"
string(5) "[bar]"
</code></pre></div>
<p dir="auto">Is this something expected ?</p>