title: How to use Symfony validation with json data
body: <p>When I'm using Symfony v5.1 array of collection validation I got a strange response.</p>
  <p>This is my code</p>
  <pre><code>   $constraint = new Assert\Collection([
          'email' =&gt; new Assert\Email(),
          'password' =&gt; new Assert\Length(['min' =&gt; 60]),
      ]);
  
      $violations = $validator-&gt;validate($request-&gt;request-&gt;all() , $constraint);
  
      foreach($violations as $violation)
      {
          $errors[] = [$violation-&gt;getPropertyPath() =&gt; $violation-&gt;getMessage()];
      }
  
      dd($errors);
  </code></pre>
  <p>and this is the result I got:</p>
  <pre><code> array:5 [
    0 =&gt; array:1 [
      &quot;[password]&quot; =&gt; &quot;This value is too short. It should have 60 characters or more.&quot;
    ]
    1 =&gt; array:1 [
      &quot;[name]&quot; =&gt; &quot;This field was not expected.&quot;
    ]
    2 =&gt; array:1 [
      &quot;[phone_number]&quot; =&gt; &quot;This field was not expected.&quot;
    ]
    3 =&gt; array:1 [
      &quot;[username]&quot; =&gt; &quot;This field was not expected.&quot;
    ]
    4 =&gt; array:1 [
      &quot;[role_id]&quot; =&gt; &quot;This field was not expected.&quot;
    ]
  ]
  </code></pre>
  <p>so I'm wondering why the name of the input is swapping in array[] <code>[name]</code>
  so is there is a wrong something I did?</p>
  <p>And why Symfony is focused on entity <code>validation</code> and not on the <code>request</code> like Laravel framework?</p>