fix(domain): validate participant name types

This commit is contained in:
nyan404 committed 2026-08-25 04:10:17 +03:00
1 parent 9dbf98fee1
commit f435b64d3c
3 files changed
+13 -2

No files matched your search

+3 -2
View File
@@ -103,7 +103,7 @@ class CoachingSession:
if self.kitten_independence not in ("самостоятельно", "несамостоятельно"):
raise ValueError("Некорректный статус самостоятельности")
for name, kitten_id, independence in self.extra_kittens:
if not name.strip():
if not isinstance(name, str) or not name.strip():
raise ValueError("Имя дополнительного котёнка не может быть пустым")
_positive_id(kitten_id, "ID дополнительного котёнка")
if independence not in ("самостоятельно", "несамостоятельно"):
@@ -239,7 +239,8 @@ class TrainingSession:
def __post_init__(self) -> None:
"""Валидирует данные сессии тренировки."""
if not self.escort_name.strip() or not self.kitten_name.strip():
if (not isinstance(self.escort_name, str) or not self.escort_name.strip()
or not isinstance(self.kitten_name, str) or not self.kitten_name.strip()):
raise ValueError("Имена участников не могут быть пустыми")
_positive_id(self.escort_id, "ID сопровождающего")
_positive_id(self.kitten_id, "ID котёнка")