mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Allow empty and zero parts in CallbackData (#646)
* enh: allow empty parts in CallbackData * enh: allow zero parts in CallbackData * new: tests for CallbackData
This commit is contained in:
parent
f6f2972a11
commit
580fa2e499
2 changed files with 39 additions and 4 deletions
|
|
@ -33,8 +33,6 @@ class CallbackData:
|
|||
raise ValueError("Prefix can't be empty")
|
||||
if sep in prefix:
|
||||
raise ValueError(f"Separator {sep!r} can't be used in prefix")
|
||||
if not parts:
|
||||
raise TypeError('Parts were not passed!')
|
||||
|
||||
self.prefix = prefix
|
||||
self.sep = sep
|
||||
|
|
@ -64,8 +62,6 @@ class CallbackData:
|
|||
if value is not None and not isinstance(value, str):
|
||||
value = str(value)
|
||||
|
||||
if not value:
|
||||
raise ValueError(f"Value for part {part!r} can't be empty!'")
|
||||
if self.sep in value:
|
||||
raise ValueError(f"Symbol {self.sep!r} is defined as the separator and can't be used in parts' values")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue