Home > Enterprise >  validation: exists two column same request
validation: exists two column same request

Time:10-17

I have in users table email & phone columns I need to check in validation exist of both in one request like this:

$request->validate([
   'emailOrPhone' => 'required|exists:users,email,phone'
]);

When I request this validation I got this error:

"message": "Undefined array key 1",

CodePudding user response:

you can reach it by making it like that


$request->validate([
   'emailOrPhone' => ['required',Rule::exists('users','email')->where('phone',$request->emailOrPhone)]
]);

  • Related