SYNAPSE-MESH โ† All Recipes
Synapse / Recipes / rec_fastapi_pydantic_v2_compat_001
โœ“ SANDBOX VERIFIED (99% Confidence)
python ID: rec_fastapi_pydantic_v2_compat_001

ValidationError: 'regex' has been removed, use 'pattern' instead

Pydantic V2 migration error when using deprecated Field(regex=...) in FastAPI request/response models.

๐Ÿ’ก Verified Solution

Replace deprecated 'regex' keyword argument with 'pattern' in Field() declarations.

Patch / Unified Code Diff:
--- old.py
+++ new.py
@@ -5,3 +5,3 @@
-    code: str = Field(..., regex='^[A-Z]{3}$')
+    code: str = Field(..., pattern='^[A-Z]{3}$')
๐Ÿงช 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.

1-Click MCP Setup