fix(core): Reorder field_validator and classmethod to fit Pydantic V2. (#5257)
This commit is contained in:
parent
e95f8fa3dc
commit
5a99aeb864
11 changed files with 17 additions and 15 deletions
|
|
@ -14,9 +14,9 @@ class ToolEntity(BaseModel):
|
|||
tool_label: str # redundancy
|
||||
tool_configurations: dict[str, Any]
|
||||
|
||||
@classmethod
|
||||
@field_validator('tool_configurations', mode='before')
|
||||
def validate_tool_configurations(cls, value, values: ValidationInfo) -> dict[str, Any]:
|
||||
@classmethod
|
||||
def validate_tool_configurations(cls, value, values: ValidationInfo):
|
||||
if not isinstance(value, dict):
|
||||
raise ValueError('tool_configurations must be a dictionary')
|
||||
|
||||
|
|
@ -32,8 +32,8 @@ class ToolNodeData(BaseNodeData, ToolEntity):
|
|||
value: Union[Any, list[str]]
|
||||
type: Literal['mixed', 'variable', 'constant']
|
||||
|
||||
@classmethod
|
||||
@field_validator('type', mode='before')
|
||||
@classmethod
|
||||
def check_type(cls, value, validation_info: ValidationInfo):
|
||||
typ = value
|
||||
value = validation_info.data.get('value')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue