Created
February 11, 2011 17:45
-
-
Save jaredhoyt/822728 to your computer and use it in GitHub Desktop.
Example password validation
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 | |
class User extends AppModel { | |
var $validate = array( | |
'first_name' => array('rule' => 'notEmpty', 'message' => 'Please enter a first name.'), | |
'last_name' => array('rule' => 'notEmpty', 'message' => 'Please enter a last name.'), | |
'phone' => array('rule' => array('phone', null, 'us'), 'allowEmpty' => true, 'message' => 'Please enter a valid phone number.'), | |
'email' => array( | |
'email' => array('rule' => array('email', true), 'message' => 'Please use a valid email address.'), | |
'isUnique' => array('rule' => 'isUnique', 'message' => 'This email address is already being used.') | |
), | |
'password_confirm' => array( | |
'characters' => array('rule' => 'alphaNumeric', 'message' => 'Please enter a valid password.', 'last' => true), | |
'confirm' => array('rule' => 'confirmPassword', 'message' => 'These passwords do not match.') | |
) | |
); | |
function confirmPassword() { | |
# Verify password and confirm match | |
return $this->data['User']['password'] == Security::hash($this->data['User']['password_confirm'], null, true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment