avoids php blowing up if an array value is passed

if incoming data has an array value set with a slug rule on it, you get 
preg_match() expects parameter 2 to be string, array given
vendor\vlucas\valitron\src\Valitron\Validator.php:571
This commit is contained in:
Elizabeth M Smith 2017-06-23 13:41:39 -04:00 committed by GitHub
parent 15171779b3
commit c729a0c4ac

View File

@ -565,6 +565,9 @@ class Validator
*/ */
protected function validateSlug($field, $value) protected function validateSlug($field, $value)
{ {
if(is_array($value)) {
return false;
}
return preg_match('/^([-a-z0-9_-])+$/i', $value); return preg_match('/^([-a-z0-9_-])+$/i', $value);
} }