Laravel validation - input must be one of items in array

前端 未结 2 788
清酒与你
清酒与你 2021-02-20 08:43

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\         


        
2条回答
  •  独厮守ぢ
    2021-02-20 09:43

    Laravel 5.7

    use Illuminate\Validation\Rule;
    
    Validator::make($data, [
        'field_name' => [
            'required',
            Rule::in(['yes', 'no', 'maybe']),
        ],
    ]);
    

提交回复
热议问题