1515
1616import json
1717import pprint
18+ import re # noqa: F401
1819from datetime import datetime
1920from typing import Any , ClassVar , Dict , List , Optional , Set
2021
21- from pydantic import BaseModel , ConfigDict , StrictInt , StrictStr
22+ from pydantic import BaseModel , ConfigDict , StrictInt , StrictStr , field_validator
2223from typing_extensions import Self
2324
2425
@@ -34,6 +35,19 @@ class ErrorResponse(BaseModel):
3435 timestamp : Optional [datetime ] = None
3536 __properties : ClassVar [List [str ]] = ["error" , "message" , "path" , "status" , "timestamp" ]
3637
38+ @field_validator ("timestamp" , mode = "before" )
39+ def timestamp_change_year_zero_to_one (cls , value ):
40+ """Workaround which prevents year 0 issue"""
41+ if isinstance (value , str ):
42+ # Check for year "0000" at the beginning of the string
43+ # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
44+ if value .startswith ("0000-01-01T" ) and re .match (
45+ r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$" , value
46+ ):
47+ # Workaround: Replace "0000" with "0001"
48+ return "0001" + value [4 :] # Take "0001" and append the rest of the string
49+ return value
50+
3751 model_config = ConfigDict (
3852 populate_by_name = True ,
3953 validate_assignment = True ,
0 commit comments