Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 5 revisions

Category:Libraries::Extended

Instead of using callbacks to add rules you can add rules by extending the validation library.

All additions are welcome

[code] <?php class MY_Validation extends CI_Validation {

var $_display_fieldname = array();

function MY_Validation()
{
    parent::CI_Validation();
}

function greater_than($str,$min)
{
    if(!is_numeric($min)){ return false; } // developer error
    if(!is_numeric($str)){ return false; }
    return $str > $min;
}

function less_than($str,$max)
{
    if(!is_numeric($max)){ return false; } // developer error
    if(!is_numeric($str)){ return false; }
    return $str < $max;
}

function equal_to($str,$eq)
{
    if(!is_numeric($eq)){ return false; } // developer error
    if(!is_numeric($str)){ return false; }
    return $str == $eq; 
}

function max_checked($str,$max)
{
    if(!is_numeric($max)){ return false; } // developer error
    return count($str) <= $max;
}

function min_checked($str,$min)
{
    if(!is_numeric($min)){ return false; } // developer error
    return count($str) >= $min;
}

function exact_checked($str,$eq)
{
    if(!is_numeric($eq)){ return false; } // developer error
    return count($str) == $eq;
}

} [/code]

Clone this wiki locally