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

A wiki is for collaboration right. I suggest we extend the validation library here together so feel free to add your code too.

=================[size=4]Rule Reference[/size]======================== [size=3]CI_Validation[/size] [code] required No Returns FALSE if the form element is empty.
matches Yes Returns FALSE if the form element does not match the one in the parameter. matches[form_item] min_length Yes Returns FALSE if the form element is shorter then the parameter value. min_length[6] max_length Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] exact_length Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] alpha No Returns FALSE if the form element contains anything other than alphabetical characters.
alpha_numeric No Returns FALSE if the form element contains anything other than alpha-numeric characters.
alpha_dash No Returns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes.
numeric No Returns FALSE if the form element contains anything other than numeric characters.
valid_email No Returns FALSE if the form element does not contain a valid email address.
valid_ip No Returns FALSE if the supplied IP is not valid. [/code] [code] [size=3]MY_Validation[/size] no_space No Returns FALSE if the supplied post contains spaces. [/code]

=================[size=4]Code[/size]========================

[size=3]no_space[/size] [url=http://codeigniter.com/forums/member/41074/]Author: TaMeR[/url] [code] /**

  • Error if there is a space
  • @author TaMeR / Dennis T. Kaplan
  • @version 1.0 */
    function no_space($str) { return ( ! preg_match("#\s#", $str)) ? FALSE : TRUE; } [/code]

=================[size=4]Language[/size]======================== [size=3]English[/size] [code]

$lang['required'] = "The %s field is required."; $lang['isset'] = "The %s field must have a value."; $lang['valid_email'] = "The %s field must contain a valid email address."; $lang['valid_url'] = "The %s field must contain a valid URL."; $lang['min_length'] = "The %s field must be at least %s characters in length."; $lang['max_length'] = "The %s field can not exceed %s characters in length."; $lang['exact_length'] = "The %s field must be exactly %s characters in length."; $lang['alpha'] = "The %s field may only contain alphabetical characters."; $lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters."; $lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes."; $lang['numeric'] = "The %s field must contain a number."; $lang['matches'] = "The %s field does not match the %s field.";

$lang['no_space'] = "The %s field may not contain spaces."; [/code]

Clone this wiki locally