CI_Form_validation::__construct PHP Method

__construct() public method

Initialize Form_Validation class
public __construct ( array $rules = [] ) : void
$rules array
return void
    public function __construct($rules = array())
    {
        $this->CI =& get_instance();
        // applies delimiters set in config file.
        if (isset($rules['error_prefix'])) {
            $this->_error_prefix = $rules['error_prefix'];
            unset($rules['error_prefix']);
        }
        if (isset($rules['error_suffix'])) {
            $this->_error_suffix = $rules['error_suffix'];
            unset($rules['error_suffix']);
        }
        // Validation rules can be stored in a config file.
        $this->_config_rules = $rules;
        // Automatically load the form helper
        $this->CI->load->helper('form');
        log_message('info', 'Form Validation Class Initialized');
    }

Usage Example

 function __construct($config = array())
 {
     parent::__construct($config);
     parent::set_message('numeric_positive', 'The {field} field must contain a decimal greater or equal than 0.');
     parent::set_message('image_base64', 'The {field} field must be a image in base64 format.');
     parent::set_message('valid_base64', 'The {field} field must be base64 data.');
 }
All Usage Examples Of CI_Form_validation::__construct