【发布时间】:2020-08-10 17:14:05
【问题描述】:
如何防止出现required_without_all验证器中存在的2个参数,例如:
return [
'user' => 'required_without_all:customer,public',
'customer' => 'required_without_all:user,public',
'public' => 'required_without_all:user,customer',
];
如何防止用户从上面一起提交 2 个密钥,例如:
http://127.0.0.1:8000/app/groups-statistics?user=10&customer=10
这些是允许的请求:
http://127.0.0.1:8000/app/groups-statistics?user=10
http://127.0.0.1:8000/app/groups-statistics?customer=10
http://127.0.0.1:8000/app/groups-statistics?public=true
不允许:
http://127.0.0.1:8000/app/groups-statistics?pubilc=true&customer=10
http://127.0.0.1:8000/app/groups-statistics?user=10&customer=10
http://127.0.0.1:8000/app/groups-statistics?public=10&customer=10
【问题讨论】:
-
你需要一个自定义的
Rule -
为什么不直接从 url 中获取第一个参数,并进行必要的验证。
标签: laravel validation laravel-5 laravel-validation