fix(api): validate nested report fields

This commit is contained in:
nyan404 committed 2026-08-25 04:06:25 +03:00
1 parent 92171731ae
commit 0aec421ad2
6 files changed
+48 -6

No files matched your search

+1 -1
View File
@@ -274,7 +274,7 @@ class InspectionReport:
if len(self.resources) > MAX_INSPECTION_RESOURCES:
raise ValueError(f"В одном отчёте может быть не более {MAX_INSPECTION_RESOURCES} ресурсов")
for name, amount in self.resources:
if not name.strip() or not isinstance(amount, int) or not 0 <= amount <= MAX_RESOURCE_AMOUNT:
if not isinstance(name, str) or not name.strip() or isinstance(amount, bool) or not isinstance(amount, int) or not 0 <= amount <= MAX_RESOURCE_AMOUNT:
raise ValueError(f"Ресурс должен иметь название и количество от 0 до {MAX_RESOURCE_AMOUNT}")