Faced the problem while using Laravel 4 validation. Here's the code:
$validator = Validator::make(
array(
'surname' => ['Laravel'],
),
array(
'surname' => 'integer|alpha_dash'
)
);
$validator->passes();
var_dump($validator->failed());
It causes error: Error: preg_match() expects parameter 2 to be string, array given
Lets suppose surname comes from user and it can be array or string.
I have two questions:
- Why alpha_dash causes error instead of normal validation error?
- Why validation continues to 'alpha_dash' rule after we got FALSE on 'integer' rule? Is this a bug?