[eluser]CroNiX[/eluser]
It would be much better to just extend the validation class with your additional rules.
/application/libraries/MY_Form_validation.php
Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Form_validation extends CI_Form_validation
{
function MY_Form_validation()
{
parent::CI_Form_validation();
}
function val_password($string) {
$this->set_message('val_password', 'The password you entered in the %s field is wrong....loser!');
return false;
}
//...add more rules
}
However, when you extend the class, this just becomes another rule available to the form validation class and not a callback rule, so it would be called like:
$this->form_validation->set_rules('password', 'Password', 'trim|required|val_password');
You also don't need to check if the function is defined before defining it this way.