title: Why the Laravel validation is not working?
body: <p>I have the form below for a user register in a conference. The form can have custom questions, in this case, it has the custom question "Phone" and is a required question so I want to validate that in Laravel. The name and surname fields should also be required.</p>
  
  <p>But the validation it´s not working properly, even if the "required" attribute is removed from the source code and the "Store Registration" button is clicked the code never enters in "<code>if ($validator-&gt;passes()) {...}</code>".</p>
  
  <p>Do you know why the validation is not working?</p>
  
  <p>storeRegistration() method:</p>
  
  <pre><code> public function storeRegistration(Request $request, $id, $slug = null)
      {
  
          $rules = [];
          $messages = [];
  
          $rules["participant_name.*"] = 'required|max:255|string';
          $rules["participant_surname.*"] = 'required|max:255|string';
  
          if (isset($request-&gt;participant_question_required)) {
  
              $messages = [
                  'participant_question.*.required' =&gt; 'Fill all mandatory fields',
              ];
  
              foreach ($request-&gt;participant_question_required as $key =&gt; $value) {
                  $rule = 'string|max:255';
  
                  if ($value) {
                      $rule = 'required|' . $rule;
  
                  }
                  $rules["participant_question.{$key}"] = $rule;
  
              }
          }
  
          $validator = Validator::make($request-&gt;all(), $rules, $messages);
  
  
          if ($validator-&gt;passes()) {
  
              dd('test');
  
              $total = Session::get('total');
  
              # user object
              $user = Auth::user();
  
              $registration = Registration::create([
                  'conference_id' =&gt; $id,
                  'main_participant_id' =&gt; $user-&gt;id,
                  'status' =&gt; ($total &gt; 0) ? 'I' : 'C',
              ]);
  
              $participants_list = $request-&gt;get('participant');
  
              foreach ($participants_list as $participant) {
                  $name = $participant['name'];
                  $surname = $participant['surname'];
                  $participant_result = Participant::create([
                      'name' =&gt; $name,
                      'surname' =&gt; $surname,
                      'registration_id' =&gt; $registration-&gt;id,
                      'registration_type_id' =&gt; $participant['rtypes']
                  ]);
  
                  if (isset($participant['question_id'])) {
                      $answer = Answer::create([
                          'question_id' =&gt; $participant['question_id'],
                          'participant_id' =&gt; $participant_result-&gt;id,
                          'answer' =&gt; $participant['answer'],
                      ]);
                  }
              }
              return redirect(route('user.index', ['user' =&gt; Auth::id()]) . '#myTickets');
          } else {
              dd($validator-&gt;errors());
          }
      }
  </code></pre>
  
  <p>Form for the user to register in a conference:
      
                </p>
  
  <pre><code>  &lt;h6 &gt; Participant - 1 - geral&lt;/h6&gt;    
  
    &lt;div class="form-group font-size-sm"&gt;
      &lt;label for="namegeral_1" class="text-gray"&gt;Name&lt;/label&gt;
      &lt;input type="text" id="namegeral_1" name="participant[1][name]" required="" class="form-control" value=""&gt;
    &lt;/div&gt;
  
    &lt;div class="form-group font-size-sm"&gt;
      &lt;label for="surnamegeral_1" class="text-gray"&gt;Surname&lt;/label&gt;
      &lt;input type="text" id="surnamegeral_1" required="" class="form-control" name="participant[1][surname]" value=""&gt;
    &lt;/div&gt;
  
    &lt;div class="form-group"&gt;
      &lt;label for="participant_question"&gt;Phone?&lt;/label&gt;
      &lt;input type="text" name="participant[1][answer]" class="form-control" required=""&gt;
      &lt;input type="hidden" name="participant_question_required[]" value="1"&gt;
      &lt;input type="hidden" value="1" name="participant[1][question_id]"&gt;
    &lt;/div&gt;
  
    &lt;input type="hidden" name="participant[1][rtypes]" value="1"&gt;
  
    &lt;h6&gt; Participant - 2 - geral&lt;/h6&gt;
  
    &lt;div class="form-group font-size-sm"&gt;
      &lt;label for="namegeral_2" class="text-gray"&gt;Name&lt;/label&gt;
      &lt;input type="text" id="namegeral_2" name="participant[2][name]" required="" class="form-control" value=""&gt;
    &lt;/div&gt;
  
    &lt;div class="form-group font-size-sm"&gt;
      &lt;label for="surnamegeral_2" class="text-gray"&gt;Surname&lt;/label&gt;
      &lt;input type="text" id="surnamegeral_2" required="" class="form-control" name="participant[2][surname]" value=""&gt;
    &lt;/div&gt;
  
    &lt;div class="form-group"&gt;
      &lt;label for="participant_question"&gt;Phone?&lt;/label&gt;
      &lt;input type="text" name="participant[2][answer]" class="form-control" required=""&gt;
      &lt;input type="hidden" name="participant_question_required[]" value="1"&gt;
      &lt;input type="hidden" value="1" name="participant[2][question_id]"&gt;
    &lt;/div&gt;
  
    &lt;input type="hidden" name="participant[2][rtypes]" value="1"&gt;
  
  
    &lt;h6&gt; Participant - 3 - plus&lt;/h6&gt;    
  
    &lt;div class="form-group font-size-sm"&gt;
      &lt;label for="nameplus_3" class="text-gray"&gt;Name&lt;/label&gt;
      &lt;input type="text" id="nameplus_3" name="participant[3][name]" required="" class="form-control" value=""&gt;
    &lt;/div&gt;
    &lt;div class="form-group font-size-sm"&gt;
      &lt;label for="surnameplus_3" class="text-gray"&gt;Surname&lt;/label&gt;
      &lt;input type="text" id="surnameplus_3" required="" class="form-control" name="participant[3][surname]" value=""&gt;
    &lt;/div&gt;
  
    &lt;input type="hidden" name="participant[3][rtypes]" value="2"&gt;
    &lt;input type="submit" class="btn btn-primary" value="Store Registration"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The     "dd($request->all(), $rules);" shows based on the fields filled by the user on the form:</p>
  
  <pre><code>array:4 [▼
    "_token" =&gt; ""
    "participant" =&gt; array:3 [▼
      1 =&gt; array:5 [▼
        "name" =&gt; "John"
        "surname" =&gt; null
        "answer" =&gt; null
        "question_id" =&gt; "1"
        "rtypes" =&gt; "1"
      ]
      2 =&gt; array:5 [▼
        "name" =&gt; "ere"
        "surname" =&gt; "ere"
        "answer" =&gt; "003"
        "question_id" =&gt; "1"
        "rtypes" =&gt; "1"
      ]
      3 =&gt; array:3 [▼
        "name" =&gt; "i"
        "surname" =&gt; "i"
        "rtypes" =&gt; "2"
      ]
    ]
    "participant_question_required" =&gt; array:2 [▼
      0 =&gt; "1"
      1 =&gt; "1"
    ]
  ]
  array:4 [▼
    "participant_name.*" =&gt; "required|string"
    "participant_surname.*" =&gt; "required|string"
    "participant_question.0" =&gt; "required|string|max:255"
    "participant_question.1" =&gt; "required|string|max:255"
  ]
  </code></pre>
  
  <p>The "<code>dd($validator-&gt;errors());</code>" shows:</p>
  
  <pre><code>MessageBag {#271 ▼
    #messages: array:2 [▼
      "participant_question.0" =&gt; array:1 [▼
        0 =&gt; "FIll all mandatory fields"
      ]
      "participant_question.1" =&gt; array:1 [▼
        0 =&gt; "Fill all mandatory fields"
      ]
    ]
    #format: ":message"
  }
  </code></pre>