title: Validate a single variable or an array in Laravel
body: <p>I want to validate a single variable like this <code>$name = "example name"</code> but I didn't a way to handle it then I decided to convert it to an array like this <code>$nameArr = ['name' =&gt; 'example name'];</code>, the validator is</p>
  
  <pre><code>$rules =
     $this-&gt;validate($nameArr, [
       'name' =&gt; 'required|max:10|regex:/^[a-zA-Z0-9]+$/u',
     ], [
        'name.required' =&gt; 'name is empty',
        'name.max' =&gt; 'name must be more less than 10 letters',
        'name.regex' =&gt; 'invalid name'
     ]
   );
  </code></pre>
  
  <p>but the Laravel gives this error </p>
  
  <blockquote>
    <p>Argument 1 passed to App\Http\Controllers\Controller::validate() must be an instance of Illuminate\Http\Request, string given</p>
  </blockquote>