namespace App\Utils\User;
class PasswordValidator {
/**
* function is checking that password have at least uppercase 8 chars, special symbols etc.
*
* @param string $password
*
* @return boolean
*/
public function validate(string $password): bool {
$uppercase = preg_match('@[A-Z]@', $password);
$lowercase = preg_match('@[a-z]@', $password);
$number = preg_match('@[0-9]@', $password);
$specialChars = preg_match('@[^\w]@', $password);
if (!$uppercase || !$lowercase || !$number || !$specialChars || mb_strlen($password, 'utf-8') < 8) {
return false;
}
return true;
}
}