CodeIgniter Forums

Full Version: Adding an extra feature to CI form_validation class
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I usually come across name checks having the following requirement:-

1 - allowed characters are alphabets and spaces
2 - min-length -> 6

We come across numerous such situations for which we do not have any method in the form_validation class. So we have to provide callbacks to check for validity inside which we check against regular expressions.

It would be very handy if we could have a method like the one below which would enable us to check for regular expressions without writing callbacks each time we need such a method which is not present in the form_validation class.

* Reg Exp
* @access public
* @param string
* @param value
* @return bool
public function reg_exp($str, $val)
     if (preg_match("$val", $str))
         return TRUE;

     return FALSE;