我正在使用表单请求验证并允许在表单中创建车辆.每辆车辆都有一个参考,可以是A、B、C或D.然而,在每个表格请求中必须始终有一个ref:"A".其他的可以有任何数量.
我无法控制形式.请求通过API发出.
我的规则数组当前包含:
'form.vehicles' => 'required',
'form.vehicles.*.ref' => 'required|in:A,B,C,D
目前我正在使用以下代码:
if (! in_array('A', $this->input('form.vehicles.*.ref'))) {
throw new HttpResponseException(response()->json(['MessageString' => 'Vehicle ref A is required'], 422));
然而,这意味着无法在针对其他验证问题的响应中发送maileBag.