Commit 067de31b by meier

mcValidator um password regExp ergänzt

1 parent ccada8aa
_htaccess
\ No newline at end of file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?)$ index.php?qrcode=$1 [QSA,L]
...@@ -11,42 +11,54 @@ class mcValidator { ...@@ -11,42 +11,54 @@ class mcValidator {
const VALIDATOR_TYPE_EMAIL = 'email'; const VALIDATOR_TYPE_EMAIL = 'email';
const VALIDATOR_TYPE_URL = 'url'; const VALIDATOR_TYPE_URL = 'url';
const VALIDATOR_TYPE_SINGELTONNAME = 'singeltonName'; const VALIDATOR_TYPE_SINGELTONNAME = 'singeltonName';
const VALIDATOR_TYPE_PHONE = 'singeltonName'; const VALIDATOR_TYPE_PHONE = 'phone';
const VALIDATOR_TYPE_GERPLZ = 'gerPlz'; const VALIDATOR_TYPE_GERPLZ = 'gerPlz';
const VALIDATOR_TYPE_YOUTUBEID = 'youtubeID'; const VALIDATOR_TYPE_YOUTUBEID = 'youtubeID';
const VALIDATOR_TYPE_VIMEOID = 'vimeoID'; const VALIDATOR_TYPE_VIMEOID = 'vimeoID';
const VALIDATOR_TYPE_PASSWORD = 'password';
private static $regExpArray = array( private static $regExpArray = array(
self::VALIDATOR_TYPE_URL => array( self::VALIDATOR_TYPE_URL => array(
'regExp' => '/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/', 'regExp' => '(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?',
'match' => true 'match' => true
), ),
self::VALIDATOR_TYPE_SINGELTONNAME => array( self::VALIDATOR_TYPE_SINGELTONNAME => array(
'regExp' => '/[^A-Za-z0-9\-]/', 'regExp' => '[^A-Za-z0-9\-]',
'match' => false 'match' => false
), ),
self::VALIDATOR_TYPE_PHONE => array( self::VALIDATOR_TYPE_PHONE => array(
'regExp' => '/[^-\s\d.\(\)\/+]/', 'regExp' => '[^-\s\d.\(\)\/+]',
'match' => false 'match' => false
), ),
self::VALIDATOR_TYPE_GERPLZ => array( self::VALIDATOR_TYPE_GERPLZ => array(
'regExp' => '/\d{5}$/', 'regExp' => '\d{5}$',
'match' => true 'match' => true
), ),
self::VALIDATOR_TYPE_YOUTUBEID => array( self::VALIDATOR_TYPE_YOUTUBEID => array(
'regExp' => '/[^A-Za-z0-9\-\_]/', 'regExp' => '[^A-Za-z0-9\-\_]',
'match' => false 'match' => false
), ),
self::VALIDATOR_TYPE_VIMEOID => array( self::VALIDATOR_TYPE_VIMEOID => array(
'regExp' => '/[\D]/', 'regExp' => '[\D]',
'match' => false 'match' => false
),
self::VALIDATOR_TYPE_PASSWORD => array(
'regExp' => '^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}',
'match' => true
) )
); );
public static function getRegExp($param_type){
if(array_key_exists($param_type,self::$regExpArray)){
return self::$regExpArray[$param_type];
}else{
return null;
}
}
/** /**
* Attention: function returns true if $param_type is not const of VALIDATOR_TYPE_* * Attention: function only checks value exists if $param_type is not const of VALIDATOR_TYPE_*
* *
* @param String $param_value * @param String $param_value
* @param String $param_type - the regexpression-type which should be used * @param String $param_type - the regexpression-type which should be used
...@@ -74,7 +86,7 @@ class mcValidator { ...@@ -74,7 +86,7 @@ class mcValidator {
case self::VALIDATOR_TYPE_EMAIL : return self::checkEmail($param_value, $param_allowNoValue); case self::VALIDATOR_TYPE_EMAIL : return self::checkEmail($param_value, $param_allowNoValue);
default : default :
if(array_key_exists($param_type,self::$regExpArray)){ if(array_key_exists($param_type,self::$regExpArray)){
$var_regExp = self::$regExpArray[$param_type]['regExp']; $var_regExp = '/'+self::$regExpArray[$param_type]['regExp']+'/';
$var_match = self::$regExpArray[$param_type]['match']; $var_match = self::$regExpArray[$param_type]['match'];
} }
else{ else{
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!