<p dir="auto">I've upgraded from Symfony 2.3 to Symfony 2.5 and encountered a problem.</p>
<p dir="auto">Before I had the following code (entity with:  <code class="notranslate">Assert\Callback(methods={"isEmailCollectionValid", "isCompanySelected"})</code>)</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    // this worked fine in Symfony 2.3 but stopped working properly in 2.5
    public function isEmailCollectionValid(ExecutionContextInterface $context)
    {
        foreach ($this-&gt;getEmails() as $id =&gt; $email) {
            $context-&gt;validateValue($email-&gt;getValue(), array(
                new Assert\Email(array(
                    'message' =&gt; &quot;'{{ value }}' is not a valid email.&quot;,
                ))
            ), 'emails['.$id.'].value');
        }
    }"><pre class="notranslate">    <span class="pl-c">// this worked fine in Symfony 2.3 but stopped working properly in 2.5</span>
    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">isEmailCollectionValid</span>(<span class="pl-smi"><span class="pl-smi">ExecutionContextInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>context</span>)
    {
        <span class="pl-k">foreach</span> (<span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">getEmails</span>() <span class="pl-k">as</span> <span class="pl-s1"><span class="pl-c1">$</span>id</span> =&gt; <span class="pl-s1"><span class="pl-c1">$</span>email</span>) {
            <span class="pl-s1"><span class="pl-c1">$</span>context</span>-&gt;<span class="pl-en">validateValue</span>(<span class="pl-s1"><span class="pl-c1">$</span>email</span>-&gt;<span class="pl-en">getValue</span>(), <span class="pl-en">array</span>(
                <span class="pl-k">new</span> <span class="pl-v">Assert</span>\<span class="pl-v">Email</span>(<span class="pl-en">array</span>(
                    <span class="pl-s">'message'</span> =&gt; "<span class="pl-s">'{{ value }}' is not a valid email.</span>",
                ))
            ), <span class="pl-s">'emails['</span>.<span class="pl-s1"><span class="pl-c1">$</span>id</span>.<span class="pl-s">'].value'</span>);
        }
    }</pre></div>
<p dir="auto">Now I have the following code:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    // this doesn't work properly (at least as I expect) in 2.5
    public function isEmailCollectionValid(ExecutionContextInterface $context)
    {
        $validator = $context-&gt;getValidator();
        $contextValidator = $validator-&gt;inContext($context);

        foreach ($this-&gt;getEmails() as $id =&gt; $email) {
            $contextValidator-&gt;atPath('emails['.$id.'].value')-&gt;validate($email-&gt;getValue(), array(
                new Assert\Email(array(
                    'message' =&gt; &quot;'{{ value }}' is not a valid email.&quot;,
                ))
            ));
        }
    }"><pre class="notranslate">    <span class="pl-c">// this doesn't work properly (at least as I expect) in 2.5</span>
    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">isEmailCollectionValid</span>(<span class="pl-smi"><span class="pl-smi">ExecutionContextInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>context</span>)
    {
        <span class="pl-s1"><span class="pl-c1">$</span>validator</span> = <span class="pl-s1"><span class="pl-c1">$</span>context</span>-&gt;<span class="pl-en">getValidator</span>();
        <span class="pl-s1"><span class="pl-c1">$</span>contextValidator</span> = <span class="pl-s1"><span class="pl-c1">$</span>validator</span>-&gt;<span class="pl-en">inContext</span>(<span class="pl-s1"><span class="pl-c1">$</span>context</span>);

        <span class="pl-k">foreach</span> (<span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">getEmails</span>() <span class="pl-k">as</span> <span class="pl-s1"><span class="pl-c1">$</span>id</span> =&gt; <span class="pl-s1"><span class="pl-c1">$</span>email</span>) {
            <span class="pl-s1"><span class="pl-c1">$</span>contextValidator</span>-&gt;<span class="pl-en">atPath</span>(<span class="pl-s">'emails['</span>.<span class="pl-s1"><span class="pl-c1">$</span>id</span>.<span class="pl-s">'].value'</span>)-&gt;<span class="pl-en">validate</span>(<span class="pl-s1"><span class="pl-c1">$</span>email</span>-&gt;<span class="pl-en">getValue</span>(), <span class="pl-en">array</span>(
                <span class="pl-k">new</span> <span class="pl-v">Assert</span>\<span class="pl-v">Email</span>(<span class="pl-en">array</span>(
                    <span class="pl-s">'message'</span> =&gt; "<span class="pl-s">'{{ value }}' is not a valid email.</span>",
                ))
            ));
        }
    }</pre></div>
<p dir="auto">I'm unable to add all the violations to the correspondent fields. Instead the path is being appended (i.e.: <code class="notranslate">1. "data.emails[0].value", 2. "data.emails[0].emails[1].value"</code>, and so on). And it seems (according to the sources), no way exists to overcome it. Older code works the same as the newer one in 2.5.</p>
<p dir="auto">Moreover, if I have more validators in the same entity (in this entity I have two of them), then the first error path is appended to the second one, which also produces wrong error path.</p>
<p dir="auto">Is it a bug or how can I fix it? Thanks.</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>