下面是我的验证规则:
$validationCondition = array(
'fname' => 'required|min:2',
'lname' => 'required|min:2',
'email' => 'required|email|unique:users,email',
'isd' => 'required|unique:users,isd',
'mobile' => 'required',
'password' => 'required'
);
$validationMessages = array(
'fname.required' => 'Please provide first name',
'fname.min' => 'First name should be atleast 3 characters long',
'lname.required' => 'Please provide last name',
'lname.min' => 'Last name should be atleast 3 characters long',
'email.required' => 'Please provide email',
'email.email' => 'Please provide a valid email id',
'email.unique' => 'This email id has already been registered. Choose any other valid email id.',
'isd.required' => 'The city name should be atleast 3 characters long',
'mobile.required' => 'Please provide mobile number',
'password.required' => 'Please provide password'
);
在用户表中,要检查isd和移动的以确保联系号码是否唯一。
怎么检查?我知道如何检查单个字段的唯一性,但不知道如何检查组合值是否唯一。
2条答案
按热度按时间jtw3ybtb1#
mobile
的unique
规则的含义为:“mobile
的值在所有现有用户中必须是唯一的,这些用户具有与请求中的值相同的isd
”。$request
这里是您正在验证的传入请求的示例(很明显)。8fsztsew2#
您可以使用如下
从文档获取更多详细信息