Skip to content

Commit 1075f5b

Browse files
committed
Fix: change ValidationError to ValueError. Possibly fixes things
1 parent c01a52a commit 1075f5b

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

src/api/api.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,6 @@ async def update_zone(zone_id: int, update: UpdateZone):
255255
)
256256

257257
return zone
258-
except ValidationError:
259-
raise HTTPException(
260-
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
261-
detail=f"One or multiple validation errors in\n{update}"
262-
)
263258
except HTTPException:
264259
raise
265260
except Exception as e:

src/api/models.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import List, Dict, TypedDict, Any, Optional, Literal
2-
from pydantic import BaseModel, field_validator, Field, ValidationError
2+
from pydantic import BaseModel, field_validator, Field
33
import json
44

55
class CreateCamera(BaseModel):
@@ -15,7 +15,7 @@ class CreateCamera(BaseModel):
1515
@classmethod
1616
def validate_title(cls, title):
1717
if len(title) < 1 or len(title) > 200:
18-
raise ValidationError(f"Invalid camera title: {title}")
18+
raise ValueError(f"Invalid camera title: {title}")
1919
return title
2020

2121
@field_validator('source')
@@ -27,28 +27,28 @@ def validate_source(cls, source):
2727
@classmethod
2828
def validate_latitude(cls, latitude):
2929
if latitude > 90 or latitude < -90:
30-
raise ValidationError(f"Invalid latitude value: {latitude}")
30+
raise ValueError(f"Invalid latitude value: {latitude}")
3131
return latitude
3232

3333
@field_validator('longitude')
3434
@classmethod
3535
def validate_longitude(cls, longitude):
3636
if longitude > 180 or longitude < -180:
37-
raise ValidationError(f"Invalid longitude value: {longitude}")
37+
raise ValueError(f"Invalid longitude value: {longitude}")
3838
return longitude
3939

4040
@field_validator('image_width')
4141
@classmethod
4242
def validate_image_width(cls, image_width):
4343
if image_width <= 0:
44-
raise ValidationError(f"Invalid image_width value: {image_width}")
44+
raise ValueError(f"Invalid image_width value: {image_width}")
4545
return image_width
4646

4747
@field_validator('image_height')
4848
@classmethod
4949
def validate_image_height(cls, image_height):
5050
if image_height <= 0:
51-
raise ValidationError(f"Invalid image_height value: {image_height}")
51+
raise ValueError(f"Invalid image_height value: {image_height}")
5252
return image_height
5353

5454
@field_validator('calib')
@@ -58,7 +58,7 @@ def validate_calib(cls, calib):
5858
try:
5959
json.dumps(calib)
6060
except:
61-
raise ValidationError(f"Invalid calibration data")
61+
raise ValueError(f"Invalid calibration data")
6262
return calib
6363

6464
class Point(BaseModel):
@@ -86,12 +86,12 @@ def validate_points(cls, v: Optional[List[Point]]) -> Optional[List[Point]]:
8686
return v
8787

8888
if len(v) != 4:
89-
raise ValidationError(f"Invalid points count: {len(v)}. Must be exactly 4 points")
89+
raise ValueError(f"Invalid points count: {len(v)}. Must be exactly 4 points")
9090

9191
for lhs in range(0, 4):
9292
for rhs in range(lhs + 1, 4):
9393
if v[lhs] == v[rhs]:
94-
raise ValidationError(f"Degenerate rectangle")
94+
raise ValueError(f"Degenerate rectangle")
9595

9696
return v
9797

0 commit comments

Comments
 (0)