Skip to content

Instantly share code, notes, and snippets.

@aqualad
Last active December 14, 2015 15:59
Show Gist options
  • Save aqualad/5111725 to your computer and use it in GitHub Desktop.
Save aqualad/5111725 to your computer and use it in GitHub Desktop.
validate string
<?php
public static function string(&$value, $display, $min, $max, $required=false)
{
$lang = lang :: get("validate");
$value = trim(strip_tags($value));
$len = strlen($value);
if($len == 0)
if(!$required)
return true;
else
return "$display ".'is required'; // $lang->v1;
if(($len < $min) || ($len > $max))
return "$display ".'must be between '. $min .' and '. $max . $lang->stringMsg; //$lang->v2 .. $lang->v3
// $display must be between [number] and [number]
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment