Skip to content

Instantly share code, notes, and snippets.

@aguimaraes
Created December 2, 2009 18:22
Show Gist options
  • Save aguimaraes/247414 to your computer and use it in GitHub Desktop.
Save aguimaraes/247414 to your computer and use it in GitHub Desktop.
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Auth_User_Model extends ORM {
/**
* Validates and optionally saves a new user record from an array.
*
* @param array values to check
* @param boolean save the record when validation succeeds
* @return boolean
*/
public function validate(array & $array, $save = FALSE)
{
$array = Validation::factory($array)
->pre_filter('trim')
->add_rules('email', 'required', 'length[4,127]', 'valid::email', array($this, 'email_available'))
->add_rules('username', 'required', 'length[4,32]', 'chars[a-zA-Z0-9_.]', array($this, 'username_available'))
->add_rules('password', 'required', 'length[5,42]')
->add_rules('password_confirm', 'matches[password]');
return parent::validate($array, $save);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment