title: Validation for an associative array in Laravel
body: <p>I have a JSON structure like this which I want to validate. </p>
  
  <pre><code>{
    "result":[{
  
              "product_id": 1,
              "client": 49,
              "ticket": 2,
              "sold_from_date": 1431588871,
              "sold_to_date": 1433122200,
              "discount_given":18,
              "cheques":[{
                "cheque_number" : 123456,
                "amount": 6000,
                "cheque_date": 1433122200,
                "bank": "UCD"
              },
              {"cheque_number" : 456234,
                "amount": 6000,
                "cheque_date": 1433122200,
                "bank": "AMB"
              }
              ]
          },
            {
  
              "product_id": 1,
              "client": 49,
              "ticket": 2,
              "sold_from_date": 1433122200,
              "sold_to_date": 1434688959
          }]
  }
  </code></pre>
  
  <p>I want to validate this JSON in Laravel. </p>
  
  <p>I tried doing this:</p>
  
  <pre><code>$validator = \Validator::make($data, []);
  
          $validator-&gt;each('result.product_id' , ['required|numeric']);
          $validator-&gt;each('result.sold_from_date' , ['required|numeric']);
          $validator-&gt;each('result.sold_to_date' , ['required|numeric']);
          $validator-&gt;each('result.cheques.cheque_number' , ['sometimes|required|numeric']);
          $validator-&gt;each('result.cheques.amount', ['sometimes|required|numeric']);
  
          return $validator;
  </code></pre>
  
  <p>I am getting this error every time: </p>
  
  <p><strong><em>Attribute for each() must be an array.</em></strong></p>
  
  <p>Also, how can I validate cheques? Because it can or cannot be in JSON. </p>