Home > Blockchain >  How to add two unique validation for one input
How to add two unique validation for one input

Time:03-29

I'm trying to validate an input like this:

$validatedPhone = $request->validate([
        'user_input' => 'required|unique:users,user_name|regex:/^09\d{9}$/|max:11|min:11',
]

Now I need to say that the value of this input does not exist at another table which is members table and member_mobile column.

But I have already defined a unique rule for the users table with user_name column.

So how to define two unique rules for two different tables for validating one input?

CodePudding user response:

Just add another rule as shown below

 $validatedPhone = $request->validate([
        'user_input' => 'required|unique:users,user_name|unique:members,member_mobile|regex:/^09\d{9}$/|max:11|min:11',
    ]
  • Related