Laravel validation min array with specified value

Viewed 37

I need to write validation for min array elements but with specified value.

I get from request field photos which contains array of arrays. Looking like that:

'photos' => [
    ['name' => 'example_name', 'type' => 'type_1'],
    ['name' => 'example_name2', 'type' => 'type_2'],
    ['name' => 'example_name3', 'type' => 'type_2'],
]

and i need to check that photos contains at least 3 elements where type = type_1

I know that exists min rule but how to check with specified key value?

Now I do it with prepareValidation and delete all other elements but it's looks terrbile

0 Answers
Related