Welcome Guest, Not a member yet? Register   Sign In
Validation
#9

[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();


Messages In This Thread
Validation - by El Forum - 10-22-2007, 03:49 AM
Validation - by El Forum - 10-22-2007, 05:17 AM
Validation - by El Forum - 10-22-2007, 07:02 AM
Validation - by El Forum - 10-22-2007, 03:02 PM
Validation - by El Forum - 10-22-2007, 03:40 PM
Validation - by El Forum - 10-22-2007, 05:27 PM
Validation - by El Forum - 10-22-2007, 06:15 PM
Validation - by El Forum - 10-22-2007, 07:16 PM
Validation - by El Forum - 10-23-2007, 07:11 AM
Validation - by El Forum - 10-23-2007, 05:47 PM
Validation - by El Forum - 10-24-2007, 12:47 AM
Validation - by El Forum - 10-24-2007, 01:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB