user image

Joseph Morgan
Published in : 2022-02-18

Method Illuminate\Validation\Validator::validateRequried does not exist.

Laravel

Hello everyone I am facing this error with laravel when I use the condition $validator->fails(); my code is 

 public function login(Request $req){ $validator = Validator::make($req->all(), [ 'email' => 'required|email', 'password' => 'requried', ]); if ($validator->fails()) { return response()->json($validator->errors(), 400); } if(Auth::guard('regular_users')->attempt(['email' => request('email') , 'password' => request('password')])){ $token = Str::random(60); $request->user()->forceFill([ 'api_token' => hash('sha256', $token), ])->save(); return response()->json([ "token" => $token ], 200); } else { return response()->json(['Error'], 400); } }

What is problem please help!

Comments

Mohamed Atef Date : 2022-02-18

Best answers

51

Best answers

51

there is no problem with the condition the only problem is in your typo of required your code is

 $validator = Validator::make($req->all(), [ 'email' => 'required|email', 'password' => 'requried', ]);

can you note “requried” correct the typo to be “required” so you need to change your condition to 

 $validator = Validator::make($req->all(), [ 'email' => 'required|email', 'password' => 'required', ]);

Good luck

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

Laravel clear cache files manually
Publish date: 2022-03-02 | Comments: 2
How to pass valiables to 404 error page in laravel?
Publish date: 2022-02-21 | Comments: 2
I want to make multiple foreign keys in Laravel, can I?
Publish date: 2022-01-27 | Comments: 5