I've got basic laravel validator for my request:
$validator = Validator::make($request->all(), [
'speciality' => 'required|array|min:1',
]);
if ($validator->fails()) {
return response([
'status' => 'error',
'error' => 'invalid.credentials',
'message' => 'error validation'
], 400);
}
speciality should be an array, so I define it as required|array|min:1
The problem is when my request has an empty array with null inside: speciality: [ null ] and this somehow passes my validator.
How can I correct it to catch this case?