[eluser]wiredesignz[/eluser]
I have created a MY_validation library which allows callbacks in Models.
Save the existing Validation library as MY_validation with only the original run() function in it.
Alter the class identifier to MY_ validation and extend it off CI_Validation.
Change this code appropriatley:
Code:
// Call the function that corresponds to the rule
if ($callback === TRUE)
{
if (strpos($rule, '->'))
{
list($class, $method) = split('->', $rule);
if ( ! method_exists($this->CI->$class, $method))
{
continue;
}
$result = $this->CI->$class->$method($_POST[$field], $param);
}
else
{
if ( ! method_exists($this->CI, $rule))
{
continue;
}
$result = $this->CI->$rule($_POST[$field], $param);
}
// If the field isn't required and we just processed a callback we'll move on...
if ( ! in_array('required', $ex, TRUE) AND $result !== FALSE)
{
continue 2;
}
}
else ....
my callback declaration then becomes 'trim|required|callback_users->is_unique[username]';