Last active
August 29, 2015 14:12
-
-
Save hamaguchi/3859558e2ef15dd817fb to your computer and use it in GitHub Desktop.
FuelPHPでパスワードとパスワード確認をValidationでやる方法
This file contains hidden or 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
$val = Validation::forge(); | |
$password = Input::post('password'); | |
$confirm_password = Input::post('confirm_password'); | |
$val->add('password', 'パスワード') | |
->add_rule('trim') | |
->add_rule('required') | |
->add_rule('min_length', 8) | |
->add_rule('max_length', 16) | |
->add_rule( | |
function($password) use ($confirm_password) { | |
if ($password === $confirm_password) { | |
return true; | |
} else { | |
Validation::active()->set_message('closure', 'パスワードと確認の値が異なりました。'); | |
return false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment