Skip to content

Commit 583c37d

Browse files
removes unnecessary validator
1 parent 4fa2a99 commit 583c37d

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

lib/models/interface.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
BaseModel,
55
PrivateAttr,
66
ConfigDict,
7-
model_validator,
87
)
9-
from bson import ObjectId
108

119

1210
class ApiBaseModel(BaseModel, ABC):
13-
_id: Optional[ObjectId] = PrivateAttr(default=None)
11+
_id: Optional[str] = PrivateAttr(default=None)
1412
model_config = ConfigDict(
1513
extra="allow",
1614
use_enum_values=True,
@@ -25,17 +23,6 @@ def set_id(self, value):
2523
def get_id(self):
2624
return self._id
2725

28-
@model_validator(mode='after')
29-
def validate_computed_id(self):
30-
"""Validate _id after model instantiation"""
31-
if self._id is not None:
32-
if not isinstance(self._id, ObjectId):
33-
try:
34-
self._id = ObjectId(str(self._id))
35-
except Exception as e:
36-
raise ValueError(f"Invalid ObjectId: {e}")
37-
return self
38-
3926
@property
4027
@abstractmethod
4128
def NAME(): # pylint: disable=invalid-name, no-method-argument

0 commit comments

Comments
 (0)