/ Published in: PHP
Expand |
Embed | Plain Text
<?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+\-.\(\)#\*\/'; }//end function public function url ($url, $length = 12, $http=TRUE) { if (self::version_check()) { $flag = null; if ($http) $flag = FILTER_FLAG_PATH_REQUIRED; return (bool) filter_var($integer, FILTER_VALIDATE_URL, $flag); }//end if }//end function public function string ($string, $charset=self::ALL, $length=1) { }//end function public function integer ($integer, $min=null, $max=null) { if (self::version_check()) { return filter_var($integer, FILTER_VALIDATE_INT, $options); }//end if }//end function public function email ($email) { if (self::version_check()) return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); && self::url($broken[1],5,FALSE) && self::string($broken[0],self::ALPHA.self::NUM.'\.\-_'); }//end function } ?>
You need to login to post a comment.
