title: Custom validation rule to validate an array
body: <p>If a user select in the form that he wants 2 tickets for the ticket type "ticket type 1" and 1 ticket for the "ticket type 2" the <code>RegistrationController</code> receives this in the <code>$request</code>:   </p>
  
  <pre><code>array:2 [▼
      "_token" =&gt; ""
      "types" =&gt; array:2 [▼
          "ticket type 1" =&gt; "2"
          "ticket type 2" =&gt; "1"
      ]
  ]
  </code></pre>
  
  <p>But I want to have a rule "StoreTicketTypeQuantity" to validate the following <strong>context</strong>:</p>
  
  <p>Each ticket type has a column minPerUser and a maxPerUser column in database. </p>
  
  <p>For example, the TicketType table has the ticket type with name "ticket type 1" with the minPerUser value as "1" and the maxPerUser value as "4". So in the select menu the user can only select values between 1 and 4 for the ticket type "ticket type 1".</p>
  
  <p>However, a user can introduce for example in the source code the quantity as "100" for the ticket type "ticket type 1", and this should result in a validate error.</p>
  
  <p><strong>Doubt:</strong></p>
  
  <p>Do you know how to in the StoreTicketTypeQuantity rule file get the dynamic values of the array to validate it?</p>
  
  <p>TicketType Model:</p>
  
  <pre><code>class TicketType extends Model
  {
      protected $fillable = [
          'name', 'price', 'minPerUser', 'maxPerUser','congress_id'
      ];
      public function congress(){
          return $this-&gt;belongsTo('App\Congress');
      }
  }
  </code></pre>
  
  <p>Rule file:</p>
  
  <pre><code>class TicketTypeQuantity implements Rule
  {
      public function __construct()
      {
      }
      public function passes($attribute, $value)
      {
  
      }
      public function message()
      {
          return 'The validation error message.';
      }
  }
  </code></pre>