在我的表单中,我有几个复选框,我希望在提交表单之前至少检查其中一个(或两者)。我的输入复选框名为car
和bike
。在我的控制器中,我正在验证我的请求
$this->validate($request, [
'content'=> 'required',
'title' => 'required',
'car | bike' => 'required', //this is not correct.
]);
我无法想象的是允许我进行上述验证的声明
答案 0 :(得分:1)
m
或强>
np.einsum()
或强>
return Validator::make($request, [
'firstName' => 'required|max:255',
'lastName' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
'checkbox' =>'required_without_all',
]);
<强>实施例强>:
return Validator::make($request, [
'firstName' => 'required|max:255',
'lastName' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
'option' =>'accepted'
]);
或强>
参考:https://laravel.com/docs/5.1/validation#available-validation-rules