From 30e5f89118d4748eebd00252d6173f3d754b97dc Mon Sep 17 00:00:00 2001 From: Ivor Barhansky Date: Wed, 24 Apr 2024 15:08:49 +0000 Subject: [PATCH] Update RegisterValidator.php --- RegisterValidator.php | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/RegisterValidator.php b/RegisterValidator.php index 4167d76..7e41378 100644 --- a/RegisterValidator.php +++ b/RegisterValidator.php @@ -12,7 +12,13 @@ class RegisterValidator { $login = preg_replace('!\s+!', ' ', $login); // remove inner spaces $login = trim($login); // remove outer spaces - if ($this->loginIsAllowed($login) && !$this->loginIsMixed($login)) { + if ( + $this->loginIsAllowed($login) && + !$this->loginIsMixed($login) && + mb_strlen($login < 2) && + mb_strlen($login) > 16 && + !strpos("!@#$%^&*()\+|/'\"", $login) + ) { $this->login = $login; } return $this; @@ -47,7 +53,7 @@ class RegisterValidator public function setPassword($password, $passwordVerify) { - if ($this->password === $passwordVerify) { + if ($this->password === $passwordVerify && mb_strlen($password) > 3) { $this->password = md5($password); } return $this; @@ -70,26 +76,14 @@ class RegisterValidator return $this; } - public function verify() + public function get() { - if (!empty($this->login) && !empty($this->email) && !empty($this->password) && !empty($this->birthday)) { - return [ - 'login' => $this->login, - 'email' => $this->email, - 'password' => $this->password, - 'birthday' => $this->birthday, - 'sex' => $this->sex, - ]; - } - return []; + return [ + 'login' => $this->login, + 'email' => $this->email, + 'password' => $this->password, + 'birthday' => $this->birthday, + 'sex' => $this->sex, + ]; } } - -$rv = new RegisterValidator(); -$values = $rv - ->setLogin($login) - ->setPassword($pass1, $pass2) - ->setEmail($email) - ->setBirthday($birthday) - ->setSex($sex) - ->verify();