Last active
December 14, 2015 15:59
-
-
Save aqualad/5111725 to your computer and use it in GitHub Desktop.
validate string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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