Skip to main content

2 posts tagged with "data-validation"

data-validation tag description

View All Tags

Pydantic for JSON Validation in Python

· 6 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

In our last article(python simpleeval examples), we built a dynamic rules engine using simpleeval. But there is a golden rule in software engineering: Garbage In, Garbage Out.

If your rules engine expects a checkout cart to have a cart_total (a number) and a user_role (a string), but the frontend accidentally sends {"cart_total": "free", "role": null}, your engine will crash. Before untrusted JSON data ever reaches your core logic, it needs to pass through a strict gatekeeper. In modern Python, that gatekeeper is Pydantic.

Drawbacks of Pydantic: A Deep Dive with Examples

· 7 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

📉 Drawbacks of Pydantic: A Deep Dive with Examples​

Pydantic is an indispensable tool in the modern Python ecosystem, powering frameworks like FastAPI and widely used for data validation. However, like any powerful abstraction, it comes with trade-offs. While it excels at validation and developer ergonomics, it introduces overhead and complexity that can become problematic in specific high-performance or dynamic scenarios.

This article explores the drawbacks of Pydantic, providing concrete code examples to illustrate where it might not be the best fit.