I actually need to do a validation, which needs to check for a filed which is
- Required
- Array
- Needs to have at least two columns
- One key name should be
correct_topic
- Other one needs to be
wrong_topic
Now I am writing the rules like the following for other fields.
return [
'category' => 'required|numeric',
'text' => 'required',
'type' => 'required|numeric|in:1,2,3',
'vendor' => 'required|numeric|exists:users,id',
'topic' => 'required|array'
];
How can I improve this and include the above mentioned validation for topic
?
I am writing these rules in a TopicRequest
class. Basically I need to check whether the filed topic
is an array which has got at least 2 columns and not more than 4 and one of the array key should be correct-topic
and others needs to be wrong_topic_1
etc.
Is there any default validation rules that can be used effectively for this situation ?