I am passing an array in a request to my api. Each value within the array must be within a pre-defined list.
If my list is: name,description,title
name, title //valid
different, title //invalid
I tried array|in:name,description,title but I think for that I can only pass a string as opposed to an array.
I understand I can use:
'values' => 'in:name',
However this is when I am passing a string in my json request body eg. { "values": "name"}. I am trying to pas an array eg. { "field": ["name", "description"]}
Can I do this without using a custom rule?
'values.*' => 'string|in:name,title,description'seems to work'values.*' => 'string|in:name,title,description'really means "for each element of the array 'values' each string element must match one of the specified values (name, title, or description)." Although you are passing an array, you are validating strings in the array.