Created
July 28, 2015 18:58
-
-
Save martinbean/49ce0931959ab86ae522 to your computer and use it in GitHub Desktop.
Check submitted value matches a hash in Laravel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Definition | |
Validator::extend('hash_matches', function ($attribute, $value, $parameters) { | |
return Hash::check($value, $parameters[0]); | |
}); | |
// Usage | |
'old_password' => 'required|hash_matches:'.$old_password, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A Laravel validation rule for matching supplied strings against a hash. Useful for change password forms where you require the user to supply their current password before changing.