Skip to content

Instantly share code, notes, and snippets.

@hamaguchi
Last active August 29, 2015 14:12
Show Gist options
  • Save hamaguchi/3859558e2ef15dd817fb to your computer and use it in GitHub Desktop.
Save hamaguchi/3859558e2ef15dd817fb to your computer and use it in GitHub Desktop.
FuelPHPでパスワードとパスワード確認をValidationでやる方法
$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