DEV Community

Cover image for The Learner’s Point #01: Pydantic — Bringing TypeScript-Like Validation to Python

The Learner’s Point #01: Pydantic — Bringing TypeScript-Like Validation to Python

Prasoon Jadon on November 23, 2026

I am not a teacher or anything. Through this series, The Learner's Point, I am not here to teach you. I am just here to share what I know and what ...
Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

A validation error that lists every bad field at once is the detail to keep. A model that refuses bad data at the boundary saves the debugging later.

Collapse
 
pjdeveloper896 profile image
Prasoon Jadon Brain Buffering •

Yes, definitely! Proper validation at the boundary goes a long way. Providing an error message that lists all the fields having invalid data rather than validating each field one by one helps tremendously. Better early detection than having to debug the same problem again later on.

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

listing every invalid field in one error is the part most people skip. one round trip instead of five, and the debugging starts at the right place.

Thread Thread
 
pjdeveloper896 profile image
Prasoon Jadon Brain Buffering •

Exactly! Validation shouldn't feel like a guessing game where developers fix one error only to discover another on the next request. Returning all invalid fields together makes debugging faster and the API experience much more developer-friendly.

Thread Thread
 
robertpaschal profile image
Odinaka Robert Nnamani •

the guessing game is the part that stings. all the fields at once and the debugging starts in the right place.

Collapse
 
emilywoodsnyc profile image
Emily Woods •

For the next instalment, I’d compare a value that gets converted successfully with one that should be rejected. That turns the model’s accepted input policy into something visible, rather than assuming every type mismatch is an error. In this Python debugging prompt, I’d use the same approach for booking inputs: write down the intended rule before asking an assistant to change validation.

Collapse
 
pjdeveloper896 profile image
Prasoon Jadon Brain Buffering •

Great idea! If we compare the value that converts and the one that should not convert, we will make the model boundaries even more clear. The point to define what kind of input should be expected by the model is really good – it means that we cannot call each type error.

Collapse
 
azharabbas profile image
Azhar Abbas •

The runtime part is the real difference, since TypeScript types disappear once the code runs while Pydantic actually checks the incoming data.

Collapse
 
pjdeveloper896 profile image
Prasoon Jadon Brain Buffering •

Spot on! That is the difference. TypeScript offers compile-time type safety, but the types do not guarantee anything in the running program. Pydantic adds more to validation as it checks incoming data when the program is running. This is why runtime validation becomes so critical in handling external input.

Collapse
 
mestonecold profile image
Shruti Shahi Brain Buffering •

great first post Prasoon! ✨🐱

Collapse
 
pjdeveloper896 profile image
Prasoon Jadon Brain Buffering •

Thank you , 💫

Collapse
 
mudassirworks profile image
Mudassir Khan •

the type conversion bullet is where i would slow down for anyone coming from TypeScript. pydantic in default mode quietly turns the string 1 into an int and the string yes into true, and we shipped a bug where a stray yes flipped a feature flag because nothing complained. strict mode on boundary models fixed it. will the next part cover lax versus strict mode and what coerces silently?