Answer the question
In order to leave comments, you need to log in
How to validate an array of objects in laravel?
There is a post request to the controller that passes the filenames to myfiles(generatedName,originalName) and the article id
axios.post('/api/articlesUploads', {myfiles: this.files, article_id:this.article_id})
$this->validate($request, [
'article_id' => 'required',
'myfiles.*.generatedName' => 'required|string|max:255',
'myfiles.*.originalName' => 'required|string|max:255',
]);
"message": "Trying to get property 'originalName' of non-object",
'myfiles.*.generatedName123' => 'required|string|max:255',
{"message":"The given data was invalid.","errors":{"myfiles.0.123generatedName":["The myfiles.0.123generatedName field is required."],"myfiles.1.123generatedName":["The myfiles.1.123generatedName field is required."]}
Answer the question
In order to leave comments, you need to log in
fun
i did it
In my controller I have
$request->validate([
'article_id' => 'required',
'myfiles.*.generatedName' => 'required|string|max:255',
'myfiles.*.originalName' => 'required|string|max:255',
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question