title: Laravel custom validation
body: <p><em>--- Custom validation class (application/libraries/validator.php) ---</em> </p>
  
  <pre class="lang-php prettyprint-override"><code> class Validator extends Laravel\Validator {
      public function validate_passwdU($attribute, $value, $parameters){
          $r_uppercase    = '/[A-Z]/';  //Uppercase
          $default_min = 1;
          if(is_numeric($parameters[0])&gt;=$default_min){
          $default_min = $parameters[0];
          }
          return (preg_match_all($r_uppercase,$value, $matches)&gt;=$default_min);       
      }
  }
  </code></pre>
  
  <p><em>--- application/language/en/validation.php ---</em></p>
  
  <pre class="lang-php prettyprint-override"><code>    "passwdU" =&gt; "The :attribute must be at least :size uppercase characters."
  </code></pre>
  
  <p><em>--- Controller ---</em></p>
  
  <pre class="lang-php prettyprint-override"><code>    $rules = array(
          'passwd' =&gt; 'required|min:8|passwdU:2'
      );
  
      $validation = Validator::make($input, $rules);
  
      if ($validation-&gt;fails())
      {
          return Redirect::to('URL')-&gt;with_errors($validation);
      }
  </code></pre>
  
  <p><em>--- Input ---</em></p>
  
  <p>passwd = 11111111</p>
  
  <p><em>--- View ---</em></p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;pre&gt;
  &lt;?php print_r($errors); ?&gt;
  &lt;/pre&gt;
  </code></pre>
  
  <p><em>--- Output ---</em></p>
  
  <pre class="lang-php prettyprint-override"><code>Laravel\Messages Object
  (
      [messages] =&gt; Array
      (
          [passwd] =&gt; Array
              (
                  [0] =&gt; validation.passwdU
              )
  
      )
      [format] =&gt; :message
  )
  </code></pre>
  
  <p>Why didn't I get the message that I defined in Language file? </p>