โ SANDBOX VERIFIED (99% Confidence)
python
ID: rec_pydantic_v2_field_validator_005
PydanticUserError: `@validator` is deprecated, use `@field_validator` instead
In Pydantic V2, the classmethod `@validator` decorator was deprecated in favor of `@field_validator` with mode='before'|'after'.
๐ก Verified Solution
Replace `@validator('field')` with `@field_validator('field')` and ensure `@classmethod` is used.
Patch / Unified Code Diff:
--- old.py
+++ new.py
@@ -1,5 +1,6 @@
-from pydantic import BaseModel, validator
+from pydantic import BaseModel, field_validator
class Model(BaseModel):
name: str
- @validator('name')
+ @field_validator('name')
+ @classmethod
def check_name(cls, v):
Official Primary Reference:
https://docs.pydantic.dev/2.0/migration/#validator-and-root_validator-are-deprecated
๐งช Sandbox Execution Evidence
Exit Code: 0
Tests Passed: 1 / 1
Confidence: 99%
Protocol: MCP 2026
Integrate this knowledge into your AI agent stack
Connect the canonical endpoint https://mcp.synapsemesh.dev in Claude, ChatGPT, or Cursor.