verify: Add isAllowedChars to check if a string contains invalid chars
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3700 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
29
verify.php
29
verify.php
@@ -220,6 +220,35 @@ class verify
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
// STRINGS //
|
||||||
|
/////////////////
|
||||||
|
/** Check if the provided value is only contains the provided chars.
|
||||||
|
* All the strings must be in UTF-8
|
||||||
|
* @param string $val The string to test
|
||||||
|
* @param string $allowedChars The allowed chars
|
||||||
|
*/
|
||||||
|
public function isAllowedChars ($val, $allowedChars)
|
||||||
|
{
|
||||||
|
return \verify::staticIsAllowedChars ($val, $allowedChars);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check if the provided value is only contains the provided chars.
|
||||||
|
* In static mode
|
||||||
|
* All the strings must be in UTF-8
|
||||||
|
* @param string $val The string to test
|
||||||
|
* @param string $allowedChars The allowed chars
|
||||||
|
*/
|
||||||
|
public function staticIsAllowedChars ($val, $allowedChars)
|
||||||
|
{
|
||||||
|
preg_match ('/^['.$allowedChars.']+/u', $val, $matches);
|
||||||
|
if (isset ($matches[0]) &&
|
||||||
|
mb_strlen ($matches[0]) === mb_strlen ($val))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
// NUMBERS //
|
// NUMBERS //
|
||||||
/////////////////
|
/////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user