title: Laravel Error to inicialice ValidationFactory
body: <p>I'm making my login system, through the LoginController controller, which in turn calls a request called loginRequest [I still have to update some names to Pascal]</p>
  <p>My request only has two rules that username and password are required.</p>
  <p>Then in a function getCredentials() I capture the username of this and validate that it is an email or not, this to give the user the option to log in both ways.</p>
  <p>To identify if the user is actually an email, create a method 'isMail' in which I establish $factory with the content validated through an alias set to Validacion\Factory , ValidationFactory, but when executing the submit button it throws me the error :</p>
  <p>Target [Illuminate\contracts\Validation\Factory] is not instantiable.</p>
  <p>Could you help me?</p>
  <p>template [login.blade.php]:</p>
  <pre class="lang-php prettyprint-override"><code>@extends('components\header')
  &lt;section class=&quot;vh-100&quot;&gt;
    &lt;div class=&quot;container-fluid h-custom&quot;&gt;
      &lt;div class=&quot;row d-flex justify-content-center align-items-center h-100&quot;&gt;
        &lt;div class=&quot;col-4&quot;&gt;
            &lt;img src=&quot;{{ URL::asset('img/logo.png') }}&quot;
            class=&quot;img-fluid&quot; height=&quot;500&quot;&gt;
        &lt;/div&gt;
        &lt;div class=&quot;col-md-8 col-lg-6 col-xl-4 offset-xl-1&quot;&gt;
          &lt;form action=&quot;{{route('samein.login')}}&quot; method=&quot;POST&quot;&gt;
            @csrf
            &lt;!-- Email input --&gt;
            &lt;div class=&quot;form-outline mb-4&quot;&gt;
              &lt;input type=&quot;text&quot; name=&quot;username&quot; class=&quot;form-control form-control-lg&quot;
                placeholder=&quot;Usuario&quot; /&gt;
              &lt;label class=&quot;form-label&quot; for=&quot;form3Example3&quot;&gt;Usuario&lt;/label&gt;
            &lt;/div&gt;
  
            &lt;!-- Password input --&gt;
            &lt;div class=&quot;form-outline mb-3&quot;&gt;
              &lt;input type=&quot;password&quot; name=&quot;password&quot; class=&quot;form-control form-control-lg&quot;
                placeholder=&quot;Contraseña&quot; /&gt;
              &lt;label class=&quot;form-label&quot; for=&quot;form3Example4&quot;&gt;Contraseña&lt;/label&gt;
            &lt;/div&gt;
  
            &lt;div class=&quot;text-rigth text-lg-start mt-4 pt-2&quot;&gt;
              &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary btn-lg&quot;
                style=&quot;padding-left: 2.5rem; padding-right: 2.5rem;&quot;&gt;Iniciar Sesión&lt;/button&gt;
            &lt;/div&gt;
  
          &lt;/form&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;
  </code></pre>
  <p>controller[LoginController.login]</p>
  <pre class="lang-php prettyprint-override"><code> &lt;?php
  
  namespace App\Http\Controllers;
  use App\Http\Requests\loginrequest;
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\DB;
  use Illuminate\Support\Facades\Auth;
  use App\Models\User;
  use Illuminate\Queue\RedisQueue;
  
  class LoginController extends Controller
  {
  
      public function index(){
          return view('login');
      }
  
      public function login( loginrequest $request ){
  
          $credentiales = $request-&gt;getCredentials();
          if( Auth::validate($credentiales) ){
              return redirect()-&gt;to('login')-&gt;withErrors('auth.failed');
          }
  
          $user = Auth::getProvider()-&gt;retrieveByCredentials($credentiales);
  
          Auth::login($user);
          return $this-&gt;authenticated($request,$user);
      }
  
      public function authenticated (Request $request,$user){
          return redirect('accountModule.indexusers');
      }
  }
  
  </code></pre>
  <p>and my Request[loginrequst.php]</p>
  <pre class="lang-php prettyprint-override"><code>use Illuminate\Foundation\Http\FormRequest;
  use Illuminate\contracts\Validation\Factory as ValidationFactory;
  
  class loginrequest extends FormRequest
  {
      /**
       * Determine if the user is authorized to make this request.
       *
       * @return bool
       */
      public function authorize()
      {
          return true;
      }
  
      /**
       * Get the validation rules that apply to the request.
       *
       * @return array&lt;string, mixed&gt;
       */
      public function rules()
      {
          return [
              //
              'username'=&gt;'required',
              'password'=&gt;'required'
          ];
      }
  
      public function getCredentials(){
          $username = $this-&gt;get('username');
  
          if( $this-&gt;isMail($username) ){ 
              return['email'=&gt; $username,
                      'password' =&gt; $this-&gt;get('password')
              ];
           }
           return $this-&gt;only('username','password');
      }
  
      public function isMail($value){
          $factory = $this-&gt;container-&gt;make(ValidationFactory::class);
          
          return !$factory-&gt;make(['username'=&gt;$value],['username'=&gt;'email'])-&gt;fails();
      }
  }
  
  </code></pre>