mirror of
https://github.com/miloszowi/everyone-mention-telegram-bot.git
synced 2025-10-26 00:46:02 +00:00
18 lines
599 B
Python
18 lines
599 B
Python
import re
|
|
|
|
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('^\w+$', group):
|
|
raise InvalidArgumentException(re.escape('Special characters are not allowed.'))
|
|
|
|
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}.'))
|