【发布时间】:2020-03-25 00:29:09
【问题描述】:
我正在尝试验证 3 个数组,如果第一个存在,它们必须具有相同的长度,因为它们是相关的。 我收到的输入是这样的:
'materiales' =>
array (
0 => '181',
1 => '191',
2 => '189',
),
'cantidades' =>
array (
0 => '27.65',
1 => '1.27',
2 => '26.24',
),
'unidades' =>
array (
0 => '0',
1 => '1',
),
对于这种输入,我想要一个验证错误,因为 'unidades'[3] 不存在,但验证器认为数据有效。我的规则是:
'materiales' => 'required|array',
'materiales.*' => 'nullable|exists:articulos,id',
'cantidades' => 'required|array',
'cantidades.*' => 'required_with:materiales.*|numeric|min:0.0001',
'unidades' => 'required|array',
'unidades.*' => 'required_with:materiales.*|required|numeric',
【问题讨论】:
标签: arrays laravel validation