['someProperty' => ['required', Rule::in(['needed', 'stuff'])]];
//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',
];
}
$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());