Added method \ncc\Utilities > Validate > nameFriendly()

https://git.n64.cc/nosial/ncc/-/issues/4
This commit is contained in:
Netkas 2022-12-17 09:38:54 -05:00
parent 46f6cbba70
commit a3c3322f28

View file

@ -258,4 +258,21 @@
return false;
}
/**
* Determines if the input is considered "name friendly" and does not
* contain any special characters, spaces or weird prefixes
*
* @param string $input
* @return bool
*/
public static function nameFriendly(string $input): bool
{
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;
}
}