在我的实例中,一个用户正在邀请另一个用户,我想检查他们邀请的用户是否不是他们自己。
因此,我有两个变量包含电子邮件和 user->电子邮件
$this->validate($request, [
'email' => 'required|email',
]);
如何将验证规则添加到验证调用中?
答案 0 :(得分:19)
您可以使用not_in
,它允许您指定要拒绝的值列表:
$this->validate($request, [
'email' => 'required|email|not_in:'.$user->email,
]);
答案 1 :(得分:3)
您可以根据laravel Document
使用Traceback (most recent call last):
File "/opt/pycharm-community-2018.1.4/helpers/pydev/pydevd.py", line 1664, in main()
File "/opt/pycharm-community-2018.1.4/helpers/pydev/pydevd.py", line 1658, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/opt/pycharm-community-2018.1.4/helpers/pydev/pydevd.py", line 1068, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/opt/pycharm-community-2018.1.4/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/root/PycharmProjects/network_scanner/network_scanner.py", line 3, in
import scapy.all as scapy
ModuleNotFoundError: No module named 'scapy'
为了即时验证您的请求:
different:field
这两个public function rules()
{
return [
'from' => 'required',
'to' => 'required|different:from',
'action' => 'required',
'access' => 'required'
];
}
和from
应该是不同的(不相同)。