Revision: 30251
Updated Code
at August 10, 2010 21:04 by james0rion
Updated Code
<?php /************************************************************************* *** Example of Usage: **************************************************** ***** Validate::string('717 123 4567',Validate::SPACE.Validate::PHONE); ** ***** returns true ******************************************************* *************************************************************************/ class Validate { const name = 'Simple Validation Class'; const version = '0.2a'; const NUM = '0-9'; const SPACE = '\s'; const ALPHA_LOWER = 'a-z'; const ALPHA_UPPER = 'A-Z'; const ALPHA = 'a-zA-Z'; const EALPHA_LOWER = 'a-zÃ�¡Ã�©Ã�ÂÂ�³�º�½� �¨�¬�²�¹�¤�«�¯�¶�¼�¿�¢�ª�®�´�»�£�±�µ�¡�¥�¦�§���°�¸�¾��'; const EALPHA_UPPER = 'A-Z���������������������������������¸����������������� ��������������'; const EALPHA = 'a-zÃ�¡Ã�©Ã�ÂÂ�³�º�½� �¨�¬�²�¹�¤�«�¯�¶�¼�¿�¢�ª�®�´�»�£�±�µ�¡�¥�¦�§���°�¸�¾��A-Z���������������������������������¸����������������� ��������������'; const PUNCTUATION = '\s\.\-_,;\/\:&"\'\?\!\(\)'; const ALL = '0-9\s\.\-_,;\/\:&"\'\?\!\(\)a-zÃ�¡Ã�©Ã�ÂÂ�³�º�½� �¨�¬�²�¹�¤�«�¯�¶�¼�¿�¢�ª�®�´�»�£�±�µ�¡�¥�¦�§���°�¸�¾��A-Z���������������������������������¸����������������� ��������������'; const PHONE = '0-9\s+\-.\(\)#\*\/'; static private function version_check() { return version_compare(PHP_VERSION, '5.2.0', '>='); }//end function public function url ($url, $length = 12, $http=TRUE) { if (strlen($url) < $length) return false; if (self::version_check()) { $flag = null; if ($http) $flag = FILTER_FLAG_PATH_REQUIRED; return (bool) filter_var($integer, FILTER_VALIDATE_URL, $flag); }//end if return !preg_match('/ /', $url) && preg_match('|^'.($http?'http(s)?://':'').'[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); }//end function public function string ($string, $charset=self::ALL, $length=1) { return strlen($string) >= $length && preg_match("|^[$charset]*\$|s", $string); }//end function public function integer ($integer, $min=null, $max=null) { if (self::version_check()) { $options = array('default'=>false); if (isset($min)) $options['min_range'] = $min; if (isset($max)) $options['max_range'] = $max; return filter_var($integer, FILTER_VALIDATE_INT, $options); }//end if return is_int($integer) && (!isset($min) || $integer>=$min) && (!isset($max) || $integer<=$max); }//end function public function email ($email) { if (self::version_check()) return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); $broken = explode('@',$email); return empty($broken[2]) && self::url($broken[1],5,FALSE) && self::string($broken[0],self::ALPHA.self::NUM.'\.\-_'); }//end function } ?>
Revision: 30250
Updated Code
at August 10, 2010 21:03 by james0rion
Updated Code
<?php /************************************************************************* *** Example of Usage: **************************************************** ***** Validate::string('717 123 4567',Validate::SPACE.Validate::PHONE); ** ***** returns true ******************************************************* *************************************************************************/ class Validate { const name = 'Simple Validation Class'; const version = '0.2a'; const NUM = '0-9'; const SPACE = '\s'; const ALPHA_LOWER = 'a-z'; const ALPHA_UPPER = 'A-Z'; const ALPHA = 'a-zA-Z'; const EALPHA_LOWER = 'a-záéÃÂóúýàèìòùäëïöüÿâêîôûãñõšåæç�ðøþ�'; const EALPHA_UPPER = 'A-Z����������������Ÿ��������Š�������'; const EALPHA = 'a-záéÃÂóúýàèìòùäëïöüÿâêîôûãñõšåæç�ðøþ�A-Z����������������Ÿ��������Š�������'; const PUNCTUATION = '\s\.\-_,;\/\:&"\'\?\!\(\)'; const ALL = '0-9\s\.\-_,;\/\:&"\'\?\!\(\)a-záéÃÂóúýàèìòùäëïöüÿâêîôûãñõšåæç�ðøþ�A-Z����������������Ÿ��������Š�������'; const PHONE = '0-9\s+\-.\(\)#\*\/'; static private function version_check() { return version_compare(PHP_VERSION, '5.2.0', '>='); }//end function public function url ($url, $length = 12, $http=TRUE) { if (strlen($url) < $length) return false; if (self::version_check()) { $flag = null; if ($http) $flag = FILTER_FLAG_PATH_REQUIRED; return (bool) filter_var($integer, FILTER_VALIDATE_URL, $flag); }//end if return !preg_match('/ /', $url) && preg_match('|^'.($http?'http(s)?://':'').'[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); }//end function public function string ($string, $charset=self::ALL, $length=1) { return strlen($string) >= $length && preg_match("|^[$charset]*\$|s", $string); }//end function public function integer ($integer, $min=null, $max=null) { if (self::version_check()) { $options = array('default'=>false); if (isset($min)) $options['min_range'] = $min; if (isset($max)) $options['max_range'] = $max; return filter_var($integer, FILTER_VALIDATE_INT, $options); }//end if return is_int($integer) && (!isset($min) || $integer>=$min) && (!isset($max) || $integer<=$max); }//end function public function email ($email) { if (self::version_check()) return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); $broken = explode('@',$email); return empty($broken[2]) && self::url($broken[1],5,FALSE) && self::string($broken[0],self::ALPHA.self::NUM.'\.\-_'); }//end function } ?>
Revision: 30249
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 10, 2010 21:01 by james0rion
Initial Code
<?php /************************************************************************ *** Example of Usage: *************************************************** ***** Validate::string('717 123 4567',Validate::NUM.Validate::PHONE); *** ***** returns true ****************************************************** ************************************************************************/ class Validate { const name = 'Simple Validation Class'; const version = '0.2a'; const NUM = '0-9'; const SPACE = '\s'; const ALPHA_LOWER = 'a-z'; const ALPHA_UPPER = 'A-Z'; const ALPHA = 'a-zA-Z'; const EALPHA_LOWER = 'a-záéÃóúýà èìòùäëïöüÿâêîôûãñõšåæçœðøþß'; const EALPHA_UPPER = 'A-ZÃÉÃÓÚÃÀÈÌÒÙÄËÃÖÜŸÂÊÎÔÛÃÑÕŠÅÆÇŒÃØÞ'; const EALPHA = 'a-záéÃóúýà èìòùäëïöüÿâêîôûãñõšåæçœðøþßA-ZÃÉÃÓÚÃÀÈÌÒÙÄËÃÖÜŸÂÊÎÔÛÃÑÕŠÅÆÇŒÃØÞ'; const PUNCTUATION = '\s\.\-_,;\/\:&"\'\?\!\(\)'; const ALL = '0-9\s\.\-_,;\/\:&"\'\?\!\(\)a-záéÃóúýà èìòùäëïöüÿâêîôûãñõšåæçœðøþßA-ZÃÉÃÓÚÃÀÈÌÒÙÄËÃÖÜŸÂÊÎÔÛÃÑÕŠÅÆÇŒÃØÞ'; const PHONE = '0-9\s+\-.\(\)#\*\/'; static private function version_check() { return version_compare(PHP_VERSION, '5.2.0', '>='); }//end function public function url ($url, $length = 12, $http=TRUE) { if (strlen($url) < $length) return false; if (self::version_check()) { $flag = null; if ($http) $flag = FILTER_FLAG_PATH_REQUIRED; return (bool) filter_var($integer, FILTER_VALIDATE_URL, $flag); }//end if return !preg_match('/ /', $url) && preg_match('|^'.($http?'http(s)?://':'').'[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); }//end function public function string ($string, $charset=self::ALL, $length=1) { return strlen($string) >= $length && preg_match("|^[$charset]*\$|s", $string); }//end function public function integer ($integer, $min=null, $max=null) { if (self::version_check()) { $options = array('default'=>false); if (isset($min)) $options['min_range'] = $min; if (isset($max)) $options['max_range'] = $max; return filter_var($integer, FILTER_VALIDATE_INT, $options); }//end if return is_int($integer) && (!isset($min) || $integer>=$min) && (!isset($max) || $integer<=$max); }//end function public function email ($email) { if (self::version_check()) return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); $broken = explode('@',$email); return empty($broken[2]) && self::url($broken[1],5,FALSE) && self::string($broken[0],self::ALPHA.self::NUM.'\.\-_'); }//end function } ?>
Initial URL
Initial Description
Initial Title
Simple Validation Class
Initial Tags
validation
Initial Language
PHP