From 7e78f63ff5846ead6694dc08211664c415a8e92d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 20 Aug 2018 18:34:26 -0600 Subject: [PATCH] Update RegisterController --- app/Http/Controllers/Auth/RegisterController.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 1b9de0513..f9ba3b648 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -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', ];