Laravel 5.2 Validation in Controller
<p>I have no view for this controller.I want to use Laravel validation to check variables. and show custom errors by returning string in controller.(I dont use view, blade, session,... I just return string) </p>

<pre><code>    if(strlen($username) &lt; 4) return '{"r": "US","msg": "username is short"}';
    if(strlen($username) &gt; 64) return '{"r": "UL","msg": "username is long"}';
    if(preg_match("/(\S*\d+\S*[[:alpha:]]+\S*)|(\S*[[:alpha:]]+\S*\d+\S*)/", $password)) return '{"r": "P","msg": "wrong password"}';
    if(strlen($name) &gt; 32) '{"r": "N","msg": "wrong name"}';
    if(strlen($address) &gt; 200) '{"r": "A","msg": "wrong address"}';
</code></pre>

<p>I want something like this:</p>

<pre><code>    'username' =&gt; 'required|min:4|max:64|unique:users|regex:/[a-zA-Z]+[a-zA-Z0-9_]*/',
    'email' =&gt; 'required|unique:users|email|min:8',
    ...
</code></pre>