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

Undefined Variable problem on Laravel 9.x
Publish date: 2022-03-06 | Comments: 3
How to get original attribute value in Laravel?
Publish date: 2022-02-23 | Comments: 3
Laravel Network is unreachable stream_socket_client 587
Publish date: 2022-02-16 | Comments: 4
Laravel API POST method returns 419
Publish date: 2022-08-03 | Comments: 1
Get user location (city - country) from his IP address
Publish date: 2022-03-02 | Comments: 2
tymon/jwt-auth 0.5.12 requires illuminate/support ~5.0
Publish date: 2022-02-18 | Comments: 2
How can i pass data from blade template to vue component?
Publish date: 2022-02-11 | Comments: 1