I am trying to validate a multi dimensional array in Laravel. This whole input itself is not required, however, if it is present, all of its keys should have some value.
My Input has dynamic input arrays. Example :
$users = [
['name' => 'John' , 'Age' => 25],
['name' => 'Nick' , 'Age' => 28]
]
My requirement is that, if a record is sent along with the request, it has to contain both name and age. At the same time, this whole array is not mandatory.
I can accept
$users = []
Cannot accept
$users = [
['name' => '' , 'Age' => 25],
['name' => 'Nick' , 'Age' => null]
]
Something like that in your Request should work:
This return false if any of the user is missing name or Age attributes.