title: laravel: vaidation vs migration schema rules
body: <p>i have a migration with the following:</p>
  
  <pre><code>Schema::create('ingredients', function (Blueprint $table) {
      $table-&gt;increments('id');
      $table-&gt;string('name',10)-&gt;unique()-&gt;nullable(false);
      $table-&gt;timestamps();
  });
  </code></pre>
  
  <p>If you note i want the string not to exceed 10 characters</p>
  
  <p>In my controller i have:</p>
  
  <pre><code>$this-&gt;validate($request, [
      'name' =&gt; 'bail|required|unique:ingredients|max:200',
  ]);
  </code></pre>
  
  <p>In the controller i have mentioned the max characters to be 200.</p>
  
  <p>So when i fill the form with more than 10 characters and less than 200 characters it get stored in the database. How is this possible.</p>
  
  <p>Will laravel not check the integrity between then migration files schema rules and the validation rules.</p>
  
  <p>Also another thing i noted is: If i remove the validation rules from the controller and submit the form, still it does not check for the number of character w.r.t 10. It creates a new database record. Where as it checks for the unique record even i dont use any validation rules.</p>
  
  <p>why unique is checked is checked irrespective of mentioning in the validation rules.</p>
  
  <p>Also the maximum number of characted (10) in the migration file has no significance. because with or without validation rules i can input name with more than 10 characters.</p>
  
  <p>Where as if i have my validation rule saying max:2 then it shows the form errors while submitting.</p>
  
  <p>So its bit confusing which work from migration file irrespective of the validation rules and which does not work at all even its mentioned in the migration table.</p>