我想验证客户提交的电子邮件地址,但如果客户提交自己的电子邮件地址,我不希望弹出错误现在我的电子邮件验证如下所示:['email', 'unique', 'targetClass' => Client::class, 'message' => 'This email address is taken']但我希望能够传递一个函数'unique'来确定是否需要应用'unique'过滤器,如下所示:['email', 'unique', 'unique' => function($value) { /* ... */ }, 'targetClass' => Client::class, 'message' => 'This email address is taken']
1 回答
精慕HU
TA贡献1845条经验 获得超8个赞
检查文档“强制唯一规则忽略给定 ID”: https: //laravel.com/docs/5.2/validation#rule-unique
'email' => 'unique:users,email_address,'.$user->id
- 1 回答
- 0 关注
- 71 浏览
添加回答
举报
0/150
提交
取消