CodeIgniter Forums
From Validation Bug or Syntax - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: From Validation Bug or Syntax (/showthread.php?tid=66368)



From Validation Bug or Syntax - Cannondale - 10-16-2016

I'm trying to call a custom validation method (), which reside in a custom library (). But I'm getting a CI error in libraries/Form_validation.php.
Not sure if this is a bug of a problem with my syntax. Code snipits below.

CONTROLLER
Code:
$this->form_validation->set_rules('name', 'Name', array($this->custom_validation_lib, '_alpha_custom'));

LIB
Code:
public function _alpha_custom($str){
    if(preg_match('/^[a-z\s\-\,\.\']*$/i', $str))
        return TRUE;
    else
        return FALSE;
}      


OUTPUT
A PHP Error was encountered

Severity: Warning

Message: preg_match() expects parameter 2 to be string, object given

Filename: libraries/Form_validation.php

Line Number: 693