How would I run a validator for every image thats in a request, when the form file names are always different.
My form file names can range from file1
all the way to section_1_image[0][]
.
I need to create a validation that I can paste in every controller, that checks the post request and validates ALL files if it has them
This is what I have so far
$validator = Validator::make($request->all(), [
'items' => 'array',
]);
$validator->each('items', [
'*' => 'max:50'
]);
if ($validator->fails()) {
echo 'Error';
exit;
}
But this doesn't seem to do anything, it just gets ignored?