$validator = Validator::make($request->all(), [
"names" => "required|array|min:3",
"names.*" => "required|string|distinct|min:3",
]);
//Be careful it does multiple queries.
//'document_group_ids.*' => 'exists:document_groups,id'
public function rules(): array
{
return [
'document_type_id' => 'required|integer|exists:document_types,id',
'document_group_ids' => 'required|array',
'document_group_ids.*' => 'exists:document_groups,id',
];
}
'item' => [ Rule::in($my_arr) ],
$request = [
'ids' => [1, 2, 3, 4],
];
$rules = [
'ids' => 'required|array',
'ids.*' => 'exists:users,id', // check each item in the array
];
$validator = Validator::make($request, $rules);
dd($validator->passes(), $validator->messages()->toArray());