mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Allow to use separators longer than 1 symbols.
Allow to use not string values.
This commit is contained in:
parent
4cc67ea03a
commit
91ceeed59a
1 changed files with 3 additions and 7 deletions
|
|
@ -31,10 +31,8 @@ class CallbackData:
|
|||
raise TypeError(f"Prefix must be instance of str not {type(prefix).__name__}")
|
||||
elif not prefix:
|
||||
raise ValueError('Prefix can\'t be empty')
|
||||
elif len(sep) != 1:
|
||||
raise ValueError(f"Length of sep should be equals to 1")
|
||||
elif sep in prefix:
|
||||
raise ValueError(f"Symbol '{sep}' can't be used in prefix")
|
||||
raise ValueError(f"Separator '{sep}' can't be used in prefix")
|
||||
elif not parts:
|
||||
raise TypeError('Parts is not passed!')
|
||||
|
||||
|
|
@ -63,14 +61,12 @@ class CallbackData:
|
|||
else:
|
||||
raise ValueError(f"Value for '{part}' is not passed!")
|
||||
|
||||
if not isinstance(value, str):
|
||||
raise TypeError(f"Value must be instance of str not {type(value).__name__}")
|
||||
elif not value:
|
||||
if not value:
|
||||
raise ValueError(f"Value for part {part} can't be empty!'")
|
||||
elif self.sep in value:
|
||||
raise ValueError(f"Symbol defined as separator can't be used in values of parts")
|
||||
|
||||
data.append(value)
|
||||
data.append(str(value))
|
||||
|
||||
if args or kwargs:
|
||||
raise TypeError('Too many arguments is passed!')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue