I keep getting this exception using laravel's custom validation and I have no idea why. Here is the full exception message:
local.ERROR: exception 'ErrorException' with message 'Argument 2 passed to Illuminate\Validation\Factory::make() must be of the type array, object given, called in /home/vagrant/Code/Spark/my-project/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 223 and defined' in /home/vagrant/Code/Spark/my-project/vendor/laravel/framework/src/Illuminate/Validation/Factory.php:91
Here is my code:
$rules = array(
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
'vat_id' => 'max:50|vat_id',
'terms' => 'required|accepted',
'address' => 'required|max:255',
'city' => 'required|max:255',
'state' => 'required',
'contactName' => 'required',
'phone' => 'numeric|required',
'zip' => 'numeric|required',
);
$validator = Validator::make($request->all(), $rules);
Now, I've also tried it like this, and I get the same exception:
$validator = Validator::make($request->all(), [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
'vat_id' => 'max:50|vat_id',
'terms' => 'required|accepted',
'address' => 'required|max:255',
'city' => 'required|max:255',
'state' => 'required',
'contactName' => 'required',
'phone' => 'numeric|required',
'zip' => 'numeric|required',
]);
As far as I can tell, I'm following the docs exactly (https://www.laravel.com/docs/5.2/validation#manually-creating-validators), and am passing an array. I've manually created validation plenty of times in laravel and never encountered this issue. I'm hoping that there's something obvious that I'm doing wrong that maybe another set of eyes can easily pick up, because this has me really stumped. Any help is very appreciated! If it makes a difference, I am using Spark.
Edit: Here's what I get when I var_dump $rules:
array (size=12)
'name' => string 'required|max:255' (length=16)
'email' => string 'required|email|max:255|unique:users' (length=35)
'password' => string 'required|confirmed|min:6' (length=24)
'vat_id' => string 'max:50|vat_id' (length=13)
'terms' => string 'required|accepted' (length=17)
'address' => string 'required|max:255' (length=16)
'city' => string 'required|max:255' (length=16)
'state' => string 'required' (length=8)
'contactName' => string 'required' (length=8)
'phone' => string 'numeric|required' (length=16)
'zip' => string 'numeric|required' (length=16)