Added method \ncc\Utilities > Validate > pathName()
https://git.n64.cc/nosial/ncc/-/issues/4
This commit is contained in:
parent
f75625633c
commit
4f30d343e5
1 changed files with 20 additions and 0 deletions
|
@ -268,6 +268,8 @@
|
||||||
*/
|
*/
|
||||||
public static function nameFriendly(string $input): bool
|
public static function nameFriendly(string $input): bool
|
||||||
{
|
{
|
||||||
|
if(strlen($input) == 0)
|
||||||
|
return false;
|
||||||
if (!preg_match('/^[a-zA-Z0-9_]+$/', $input))
|
if (!preg_match('/^[a-zA-Z0-9_]+$/', $input))
|
||||||
return false;
|
return false;
|
||||||
if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $input))
|
if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $input))
|
||||||
|
@ -275,4 +277,22 @@
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates if the given input is a valid path name
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function pathName(string $input): bool
|
||||||
|
{
|
||||||
|
if(strlen($input) == 0)
|
||||||
|
return false;
|
||||||
|
if (!preg_match('/^[a-zA-Z0-9_\-\/]+$/', $input))
|
||||||
|
return false;
|
||||||
|
if (!preg_match('/^[a-zA-Z_\-\/][a-zA-Z0-9_\-\/]*$/', $input))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue