Title: Validate Nested Array in laravel API Controller
Tags: php;laravel;eloquent
Question: enter image description herei want to validate $request-&gt;form_data['bench_id']; field in laravel API Controller usinfg below getvalidator function but when i pass null to bench_id exception throw an error &quot;Undefined index: bench_id&quot;
My Validation function
protected function getValidator(Request $request)
$rules = [
'form_data.*.bench_id' =&gt; 'nullable'
];
return Validator75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0make($request-&gt;all(), $rules);
My form data input values here showing in the picture
Comment: Bench Number:

`

Comment: please include input data format too.

Comment: do `dd($request->all());` and include it in question itself.

Comment: check my answer, it should work for you.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:09/18/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<php><laravel><eloquent>', 'Title': 'Validate Nested Array in laravel API Controller', 'ViewCount': 84, 'id': 63951687, 'user_AboutMe': None, 'user_AccountId': 19541407.0, 'user_DisplayName': 'Zulqarnain Qasim', 'user_Reputation': 1.0, 'user_Views': 5.0, 'user_id': 14299081.0}}