【发布时间】:2019-07-10 21:24:14
【问题描述】:
我在 Laravel 的请求中使用验证。我想根据另一个属性的划分来处理一个属性。怎么可能控制?
public function rules()
{
return [
'number' => 'required|numeric',
'threshold' =>['numeric',
function ($attribute, $value, $fail) {
if ($attribute > 'number/2') {
$fail(('threshold must be smaller than division of number'));
}
}, ]
];
}
【问题讨论】:
标签: laravel validation request attributes