Update RegisterController

This commit is contained in:
Daniel Supernault 2018-08-20 18:34:26 -06:00
parent 944a7fe8d3
commit 7e78f63ff5
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -51,11 +51,22 @@ class RegisterController extends Controller
protected function validator(array $data)
{
$this->validateUsername($data['username']);
$usernameRules = [
'required',
'alpha_dash',
'min:2',
'max:15',
'unique:users',
function($attribute, $value, $fail) {
if(!ctype_alpha($value[0])) {
return $fail($attribute . ' is invalid. Username must be alpha-numeric and start with a letter.');
}
}
];
$rules = [
'name' => 'required|string|max:255',
'username' => 'required|alpha_dash|min:2|max:15|unique:users',
'username' => $usernameRules,
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
];