[eluser]satej[/eluser]
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.
Code:
/**
* 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;
}