我的应用程序允许用户同时上传多个图像文件,但是我无法弄清楚如何验证图像数组。Laravel 5中的图像数组验证
$input = Request::all();
$rules = array(
...
'image' => 'required|image'
);
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
$messages = $validator->messages();
return Redirect::to('venue-add')
->withErrors($messages);
} else { ...
此验证将失败,因为'image'
是一个数组,如果我改变了验证规则:
$rules = array(
...
'image' => 'required|array'
);
审定会通过,但数组中的图像还没有被验证。
This answer使用每个关键字作为前缀验证规则,但是这是在laravel 4.2中,而在Laravel 5中似乎不起作用。
我一直在尝试迭代每个图像上的数组和验证,但有没有一个内置函数为我做这个?