diff --git a/src/repository/groupRepository.py b/src/repository/groupRepository.py index 43832e0..004683f 100644 --- a/src/repository/groupRepository.py +++ b/src/repository/groupRepository.py @@ -50,7 +50,7 @@ class GroupRepository: Group(chat_id, group_name, group[self.count]) ) - if not groups: + if not result: raise NotFoundException return result diff --git a/src/validator/groupNameValidator.py b/src/validator/groupNameValidator.py index 3eca5e4..4c89902 100644 --- a/src/validator/groupNameValidator.py +++ b/src/validator/groupNameValidator.py @@ -4,13 +4,14 @@ from exception.invalidArgumentException import InvalidArgumentException class GroupNameValidator: + MAX_GROUP_NAME_LENGTH: int = 20 @staticmethod def validate(group: str) -> None: group = group.lower() - if len(group) > 0 and not re.match(r"^[A-Za-z]+$", group): - raise InvalidArgumentException(re.escape('Group name must contain only letters.')) + if len(group) > 0 and not re.match('^\w+$', group): + raise InvalidArgumentException(re.escape('Special characters are not allowed.')) - if len(group) > 20: - raise InvalidArgumentException(re.escape(f'Group name length can not be greater than 20.')) + if len(group) > GroupNameValidator.MAX_GROUP_NAME_LENGTH: + raise InvalidArgumentException(re.escape(f'Group name length can not be greater than {GroupNameValidator.MAX_GROUP_NAME_LENGTH}.'))