mirror of
https://github.com/miloszowi/everyone-mention-telegram-bot.git
synced 2025-05-20 09:14:07 +00:00
group name validation changed to accept all alphanumeric characters, fixed no groups reply
This commit is contained in:
parent
b451569ddb
commit
fb223556cb
@ -50,7 +50,7 @@ class GroupRepository:
|
||||
Group(chat_id, group_name, group[self.count])
|
||||
)
|
||||
|
||||
if not groups:
|
||||
if not result:
|
||||
raise NotFoundException
|
||||
|
||||
return result
|
||||
|
@ -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}.'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user