Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel validation - input must be one of items in array

Is there a built in validator in Laravel 5 that checks if value is in array of my whitelisted values sort of speak.. Something like:

$rules = [
    'field_name' => "required|in_array('yes', 'no', 'maybe')",
];
like image 933
user3702861 Avatar asked Jun 03 '15 09:06

user3702861


1 Answers

There's in

$rules = [
    'field_name' => "required|in:yes,no,maybe",
];
like image 117
lukasgeiter Avatar answered Oct 03 '22 05:10

lukasgeiter