title: Is there a way to alias input names in the rules for Laravel 5 validation?
body: <p>I like the feature in Laravel 5 that let's me throw my validation logic into one of Laravel 5's Form Requests and then <a href="http://laravel.com/docs/5.0/validation#controller-validation" rel="noreferrer">Laravel will automatically validate it just before</a> my controller's method is ran. However, one thing that is missing is an easy way to "alias" an input name. </p>
  
  <p>For example (for simplicity sake), say I have a login form with an input field called "username" but it actually accepts an email address. The label on my form says <em>Email</em>. If there's an error, the error will say something like "Username is required". This is confusing since I'm labeling the field as <em>Email</em> on my form.</p>
  
  <p><strong>What's a good solution for aliasing inputs when using Laravel's validator?</strong></p>
  
  <p>So far I've come up with two ideas:</p>
  
  <p><strong>Solution 1:</strong>  Use Laravel's custom error messages for each rule   </p>
  
  <pre><code>&lt;?php namespace App\Http\Requests;
  
  use App\Http\Requests\Request;
  
  class AuthLoginRequest extends Request {
  
      public function rules()
      {
          return [
              'username' =&gt; 'required|email',
              'password' =&gt; 'required'
          ];
      }
  
      // This is redundant. And may have other pitfalls?
      public function messages()
      {
          return [
              'username.required' =&gt; 'email is required.',
              'username.email' =&gt; 'email is invalid.'
          ];
      }
  
      ...
  }
  </code></pre>
  
  <p><strong>Solution 2:</strong> Use my own custom form class to handle changing the input names to their label/alias (<em>username</em> becomes <em>email</em> for validation purposes), running validation, then changing them back.</p>