Created
February 13, 2012 13:44
-
-
Save jmm/1817056 to your computer and use it in GitHub Desktop.
Experimenting with password length validation within Kohana 3.2 ORM validation system
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 Model_User extends Model_Auth_User { | |
protected $_raw_data; | |
public function rules() { | |
$rules = parent::rules(); | |
$rules[ 'username' ][] = array( 'regex', array( ':value', "/^[a-zA-Z][a-zA-Z0-9-]+$/D" ) ); | |
$rules[ 'username' ][] = array( 'max_length', array( ':value', 24 ) ); | |
if ( $this->changed( 'password' ) ) { | |
$rules[ 'password' ][] = array( 'min_length', array( $this->_raw_data[ 'password' ], 8 ) ); | |
} | |
// if | |
return $rules; | |
} | |
// rules | |
protected function run_filter( $field, $value ) { | |
$this->_raw_data[ $field ] = $value; | |
return parent::run_filter( $field, $value ); | |
} | |
// run_filter | |
} | |
// Model_User | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment