Laravel 5.5 or newer
You can use the same array validation syntax that is available in the Validator
, so the code in the question now works:
public function rules(){ return ['id' => 'required','slide' => 'array|min:1','slide.*.title' => 'required|max:255','slide.*.description' => 'required|max:255', ];}
Laravel 5.4 or older
Disclaimer: This solution was posted in the question by Alexej. Since answers shouldn't be shared in the question body and the OP seems to be inactive, I repost his answer as a community wiki for future readers:
I've found the solution by getting the slide array and loop through it.
public function rules(){ $rules = ['id' => 'required','slide' => 'array|min:1', ]; foreach($this->request->get('slide') as $key => $val){ $rules['slide.'.$key.'.title'] = 'required|max:255'; $rules['slide.'.$key.'.description'] = 'required|max:255'; } return $rules;}