We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1002eaa commit b7738beCopy full SHA for b7738be
backend/python/app/models/driver_history.py
@@ -8,20 +8,23 @@
8
# if TYPE_CHECKING:
9
# from .driver import Driver
10
11
+MIN_YEAR = 2025
12
+MAX_YEAR = 2100
13
+
14
15
class DriverHistoryBase(SQLModel):
16
"""Shared fields between table and API models"""
17
18
driver_id: int = Field(
- foreign_key="drivers.id", index=True
19
+ foreign_key="drivers.driver_id", index=True
20
) # TODO FK to driver table, to validate later
21
year: int = Field(nullable=False)
22
km: float = Field(nullable=False)
23
24
@field_validator("year")
25
@classmethod
26
def validate_year(cls, v: int) -> int:
- if not 2025 <= v <= 2100:
27
+ if not (MIN_YEAR <= v <= MAX_YEAR):
28
raise ValueError("Year must be between 2025 and 2100")
29
return v
30
0 commit comments