I need to validate checkbox array:
<input name="cats[]" type="checkbox" value="1"> sport
<input name="cats[]" type="checkbox" value="2"> music
<input name="cats[]" type="checkbox" value="3"> business
I found "array" validation in documentation:
Validator::make(
[ 'cats' => Input::get('cats') ],
[ 'cats' => 'array' ]
);
Is there any built-in way to check if at least one item checked? Also, how to check if values submitted match a given list?
Bit late to this party but surely just making it "required" will suffice?
You can use min:value to validate a numeric value and you can also use it to validate an array's size.
Examples:
As of laravel 5 you can just add required rule
If you don't mind touching your input data, you could do: