title: Validation in dynamic form Laravel 5.5
body: <p>How can I create a validtion for a dynamic form?</p>
  
  <pre><code>//Controller
  public function store(Request $request)
  {       
      $rules = [
          'companyName' =&gt; 'required',
          'bannerName' =&gt; 'required',
          'bannerDescription' =&gt; 'required',
          'bannerURL' =&gt; 'required',
          'bannerImg' =&gt; 'required',
      ];
  
      $customMessages = [
          'companyName.required' =&gt; 'Yo, what should I call you?',
          'bannerName.required' =&gt; 'Yo, what should I call you?',
          'bannerDescription.required' =&gt; 'Yo, what should I call you?',
          'bannerURL.required' =&gt; 'Yo, what should I call you?',
          'bannerImg.required' =&gt; 'Yo, what should I call you?',
      ];
  
      $this-&gt;validate($request, $rules, $customMessages);
  }
  </code></pre>
  
  <p>And here is my view, my "name" attr are arrays cause I'll store a bulk of data to DB. Clicking on "+ Add Banner" jquery will clone div with the same 4 inputs.
  If I'll remove arrays everything will work ofc, but if no I'll get the following error</p>
  
  <blockquote>
    <p>htmlspecialchars() expects parameter 1 to be string, array given</p>
  </blockquote>
  
  <pre><code>{!! Form::open(['action' =&gt; 'CompanyController@store', 'method' =&gt; 'POST', 'enctype' =&gt; 'multipart/form-data']) !!}
                          &lt;div class="form-group{{ $errors-&gt;has('companyName') ? ' has-error' : '' }}"&gt;
                              &lt;label for="companyName"&gt;Company URL Address&lt;/label&gt;    
                                  &lt;input type="text" class="form-control" value="{{old('companyName')}}" id="companyName" name="companyName" placeholder="example.com"&gt;
                                  &lt;small class="text-danger"&gt;{{ $errors-&gt;first('companyName') }}&lt;/small&gt;        
                          &lt;/div&gt;
  
                          &lt;hr&gt;
  
                           &lt;div data-sel-baner-box&gt;                         
                              &lt;div data-sel-baner-form&gt;
                                      &lt;div class="panel-heading"&gt;&lt;h4 style="text-align: center"&gt;New banner&lt;/h4&gt;&lt;/div&gt;
  
                                      &lt;div class="form-group{{ $errors-&gt;has('bannerName') ? ' has-error' : '' }}"&gt;
                                          &lt;label for="bannerName"&gt;Title&lt;/label&gt;     
                                          &lt;input type="text" class="form-control" id="bannerName" value="{{old('bannerName')}}" name="bannerName[]" placeholder="Name"&gt;
                                          &lt;small class="text-danger"&gt;{{ $errors-&gt;first('bannerName') }}&lt;/small&gt;
                                      &lt;/div&gt;
  
                                      &lt;div class="form-group{{ $errors-&gt;has('bannerDescription') ? ' has-error' : '' }}"&gt;
                                          &lt;label for="bannerDescription"&gt;Banner Description&lt;/label&gt;
                                          &lt;input type="text" class="form-control" id="bannerDescription" value="{{old('bannerDescription')}}" name="bannerDescription[]" placeholder="Description"&gt;
                                          &lt;small class="text-danger"&gt;{{ $errors-&gt;first('bannerDescription') }}&lt;/small&gt;
                                      &lt;/div&gt;
  
                                      &lt;div class="form-group{{ $errors-&gt;has('bannerURL') ? ' has-error' : '' }}"&gt;
                                          &lt;label for="bannerURL"&gt;Banner URL&lt;/label&gt;
                                          &lt;input type="text" class="form-control" id="bannerURL" value="{{old('bannerURL')}}" name="bannerURL[]" placeholder="URL"&gt;
                                          &lt;small class="text-danger"&gt;{{ $errors-&gt;first('bannerURL') }}&lt;/small&gt;
                                      &lt;/div&gt;
  
                                      &lt;div class="form-group{{ $errors-&gt;has('bannerImg') ? ' has-error' : '' }}"&gt;
                                          &lt;label for="bannerImg"&gt;File input&lt;/label&gt;
                                          &lt;input type="file" class="form-control-file" id="bannerImg" name="bannerImg[]"&gt;
                                          &lt;small class="text-danger"&gt;{{ $errors-&gt;first('bannerImg') }}&lt;/small&gt;
                                     &lt;/div&gt;
                                 &lt;/div&gt;
  
                         &lt;a href="##" data-sel-btn-add-baner class="btn btn-primary"&gt;+ Add Banner&lt;/a&gt;
                         &lt;button type="submit" class="btn btn-primary"&gt;Save Company&lt;/button&gt; 
  
                      {!! Form::close() !!}       
  </code></pre>
  
  <p>Any hints please?</p>