Skip to content

Ignore empty validation rules #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Ignore empty validation rules #708

wants to merge 1 commit into from

Conversation

vpetrov
Copy link

@vpetrov vpetrov commented May 24, 2012

I accidentally created a validation rule, like so: 'required|', and got an error (see below) from Laravel because there is no second rule after the pipe character. This patch makes Laravel ignore empty rules, since there is no harm in doing so.


Unhandled Exception

Message:

Method [] does not exist.
Location:

/laravel/validator.php on line 1066
Stack Trace:
#0 /laravel/validator.php(186): Laravel\Validator->call('validate', Array)
#1 /laravel/validator.php(186): Laravel\Validator->validate
('password_confir...', 'asd', Array, Object(Laravel\Validator))
#2 /laravel/validator.php(161): Laravel\Validator->check('password_confir...', '')
#3 /laravel/validator.php(147): Laravel\Validator->valid()
#4 /laravel/validator.php(137): Laravel\Validator->invalid()
#5 /application/controllers/user.php(41): Laravel\Validator->fails()
#6 [internal function]: User_Controller->post_create()
#7 /laravel/routing/controller.php(323): call_user_func_array(Array, Array)
#8 /laravel/routing/controller.php(283): Laravel\Routing\Controller->response('create', Array)
#9 /laravel/routing/controller.php(165): Laravel\Routing\Controller->execute('create', Array)
#10 /laravel/routing/route.php(153): Laravel\Routing\Controller::call('user@(:1)', Array)
#11 /laravel/routing/route.php(124): Laravel\Routing\Route->response()
#12 /laravel/laravel.php(125): Laravel\Routing\Route->call()
#13 /public/index.php(34): require('/larave...')
#14 {main}

…a validator rule is empty, i.e.: "required|".
@taylorotwell
Copy link
Member

Don't really like to put in "babysitter" features like this. Thanks for alerting us to the error though!

flap152 pushed a commit to flap152/laravel that referenced this pull request Nov 24, 2017
flap152 pushed a commit to flap152/laravel that referenced this pull request Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants