From 13df43113a016447585760b56f936c1ef4375554 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 26 Jul 2022 18:57:58 -0400 Subject: [PATCH] Added PackageName() to \ncc\Utilities > Validate --- src/ncc/Utilities/Validate.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index 1ca050d..1adc283 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -108,4 +108,25 @@ return true; } + + /** + * Validates if the package name is valid + * + * @param $input + * @return bool + */ + public static function PackageName($input): bool + { + if($input == null) + { + return false; + } + + if((bool)preg_match("/^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$/", $input) == false) + { + return false; + } + + return true; + } } \ No newline at end of file