. */ namespace SP\Mvc\Controller\Validators; /** * Class Validator * * @package SP\Util */ final class Validator { public static function hasLetters(string $string): bool { return preg_match('#[a-z]+#i', $string) === 1; } public static function hasNumbers(string $string): bool { return preg_match('#[\d]+#', $string) === 1; } public static function hasUpper(string $string): bool { return preg_match('#[A-Z]+#', $string) === 1; } public static function hasLower(string $string): bool { return preg_match('#[a-z]+#', $string) === 1; } public static function hasSymbols(string $string): bool { return preg_match('#[$-/:-?{-~!"^_`\[\]]+#', $string) === 1; } public static function matchRegex(string $string, string $regex): bool { return preg_match('#' . str_replace('#', '\#', $regex) . '#', $string) === 1; } public static function isRegex(string $regex): bool { return @preg_match('#' . str_replace('#', '\#', $regex) . '#', null) !== false; } }