Skip to content

Commit fde9a06

Browse files
authored
Validate image_ids to prevent empty or invalid inputs (#1253)
1 parent e3ee7e6 commit fde9a06

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

backend/app/schemas/album.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ class GetAlbumImagesRequest(BaseModel):
4949
class ImageIdsRequest(BaseModel):
5050
image_ids: List[str]
5151

52+
@field_validator("image_ids")
53+
def validate_image_ids(cls, value: List[str]) -> List[str]:
54+
if not value:
55+
raise ValueError("image_ids cannot be empty")
56+
57+
cleaned = []
58+
for img_id in value:
59+
if not img_id or not img_id.strip():
60+
raise ValueError("image_ids must not contain empty values")
61+
cleaned.append(img_id.strip())
62+
63+
return cleaned
64+
5265

5366
# ##############################
5467
# Response Handler

0 commit comments

Comments
 (0)