diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index 368f6ac..46297a0 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -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; + } } \ No newline at end of file