Level 7
Found it just after I posted :)
'type' => Rule::in($allowedTypes)
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm sorry I'm sure something like this is done before, I'm just not sure I've found a clean solution. I want to use validation rules to check for actual allowed values in the request body:
$allowedValues = ['blah1', 'blah2', 'blah3'];
$rules = [
'type' => `must be any of $allowedValues`
];
Is there a laravely way to do this, or do I need a custom function to loop through the values and return boolean valid or not ?
thanks
Found it just after I posted :)
'type' => Rule::in($allowedTypes)
Please or to participate in this conversation.