Level 20
'categories' => 'required|array|max:3',
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I have a request class that validate an array of categories that each one of them have an id
Now I want to check count of received categories and limited to 3, how can I check it?
Request class:
class PlaceCategory extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'categories' => 'required|array',
'categories.id' => 'required|numeric|integer|regex:/^[0-9]+$/',
];
}
}
Please or to participate in this conversation.