Laravel-Model-Validation icon indicating copy to clipboard operation
Laravel-Model-Validation copied to clipboard

Validation on Update Method

Open danhanly opened this issue 9 years ago • 1 comments

Within my controller's update function, I run some code to save any updated fields to the database.

My password has the following validation required|between:8,20 If the password field has not changed I reapply the existing password to the field so that the required validation is satisfied. However, now, as it's a hashed password of 60 characters in length, the between rule fails.

Ideally, I'd like for the password to only be required for create methods, but to not be required for update methods. Is this possible?

danhanly avatar Oct 15 '14 06:10 danhanly

@danhanly, maybe you need to implement something like http://laravel.com/docs/4.2/validation#conditionally-adding-rules?

likerRr avatar Oct 31 '14 06:10 likerRr