[eluser]CroNiX[/eluser]
Why don't you just extend CI's validation library with your own rules?
/application/libraries/MY_Form_validation.php
Code:
class MY_Form_validation extends CI_Form_validation {
function __construct()
{
parent::__construct():
}
// don't need to user underscore to make private since its
// in the library now and not your controller
function Valid_Date_Format($date)
{
$converted=str_replace('/','-',$date);
if(preg_match("/^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))$/",$converted)===1)
{
return TRUE;
}
// Don't need to reference the form_validation object since that is now $this
$this->set_message('Valid_Date_Format', 'The Date entered is invalid.');
return FALSE;
}
}
Now when setting your rules, you just use the rule name "as is" like the native rules
instead of "callback_rule_name".
Code:
$this->form_validation->set_rules('field', 'Field', 'required|Valid_Date_Format');