【发布时间】:2016-01-26 21:51:19
【问题描述】:
我想制作一个 laravel 验证器来验证数组中未命名数组 (0,1,2,3) 中的字段
所以我的数组就像
array [ //the form data
"items" => array:2 [ //the main array i want to validate
0 => array:2 [ // the inner array that i want to validate its data
"id" => "1"
"quantity" => "1000"
]
1 => array:2 [
"id" => "1"
"quantity" => "1000"
]
// other fields of the form,
]
]
所以我想要的是类似的东西
$validator = Validator::make($request->all(), [
'items.*.id' => 'required' //notice the star *
]);
【问题讨论】:
标签: php laravel laravel-5 laravel-5.1