diff --git a/routes/api.php b/routes/api.php index c8e0c7d..f471807 100644 --- a/routes/api.php +++ b/routes/api.php @@ -12,10 +12,18 @@ Route::group(['prefix' => 'auth'], function () { Route::get('/register', function () { + $emailValidator = Validator::make(request()->all(), [ + 'email' => 'required|string|max:255|unique:users', + ]); + + if ($emailValidator->fails()) { + return response()->json(['data' => 'unique'], 200); + } + $validator = Validator::make(request()->all(), [ 'name' => 'required|string|max:255', - 'email' => 'required|string|email|max:255|unique:users', - 'password' => 'required|string|min:6', + 'email' => 'required|string|max:255|unique:users', + 'password' => 'required|string', ]); if ($validator->fails()) { @@ -33,8 +41,8 @@ Route::get('/login', function () { $validator = Validator::make(request()->all(), [ - 'email' => 'required|string|email|max:255', - 'password' => 'required|string|min:6', + 'email' => 'required|string|max:255', + 'password' => 'required|string', ]); if ($validator->fails()) {