Exemple #1
0
 /**
  * Validates and optionally saves a new user record from an array.
  *
  * @param  array    values to check
  * @param  boolean  save[Optional] the record when validation succeeds
  * @return boolean
  */
 public function validate(array &$array, $save = FALSE)
 {
     // Initialise the validation library and setup some rules
     $array = Validation::factory($array);
     // uses PHP trim() to remove whitespace from beginning and end of all fields before validation
     $array->pre_filter('trim');
     // Add Rules
     $array->add_rules('name', 'required', 'unique');
     // Email unique validation
     //$array->add_callbacks('email', array($this, '_unique_name'));
     //$array->add_rules('name', 'required', array($this, '_name_exists'));
     return parent::validate($array, $save);
 }