[eluser]Michael Ekoka[/eluser]
Hey Schnoodles, I don't know if I properly understand what you're asking, but this is what I would do:
- to create callback methods in your controller to check uniqueness and password validity:
Code:
function _is_unique($data){
// set the validator error message here
$this->validation->set_message('_is_unique', 'The %1$s is already taken.');
// do your normal queries to the database here to check if something is unique.
// If not return false. The validator doesn't care what happens here, it just cares
// to see if the callback returns false, in which case the previously set error
// message is displayed.
}
function _valid_password($username){
// set the validator error message here
$this->validation->set_message('_valid_password', 'The Password is incorrect.');
// do your normal authentication routines here
}
Alternatively, you can look for the language file /language/english/validation_lang.php and add your error messages there. Following the format that you find in the file, just put the name of the callback method and the custom error message.
- Now to authenticate and use the validation mechanism you would do this upon submit:
Code:
$rules['username'] = 'callback__valid_password';
$fields['username'] = 'User name';
$fields['password'] = 'Password';
$this->validation->set_rules($rules);
$this->validation->set_fields($fields);
$valid = $this->validation->run();