Power up data validation with Pydantic
Naveen S (~naveen18) |
Ever had a situation where you wrote a validation class for your data and you had to keep reiterating because the data kept changing? Is validation becoming hard to manage? What if Python Type hints can be used to validate your data against types, data format, null checks, variations, different sources. Additionally, you also can validate further condition which can be defined by yourself. That's what Pydantic can do. It's a data validation and settings management library in Python that works with just type hints. Pydantic solves major problems faced with validating even inconsistent data. Imagine a JSON object where certain key, value pairs are not always present or redundant. Instead of writing a lot of if conditions or match case statements a class definition is all it takes to serialise and de-serialise the objects.
I discovered the uses of Pydantic while working on an internal project in my organisation. Pydantic helped us replace a lot of code and make it more readable. This talk will highlight certain features that are really useful in day to day Data handling in Python along with few use cases that will help you get started immediately.
In this talk, we will,
- Look at common problems in data validation
- General type validations
- List item
- Python usage experience
- OOPS terminologies (not strictly)
I am a developer who writes code to solve real problems. I came from CPP, Java to PHP, Perl, JS to Go and Python. I usually make APIs, write automation scripts and do DevOps mostly. Although my heart says I'm a developer, my passion lies around Information Security. I am a Security Engineer at Freshworks Inc., writing code to perform a lot of Security tasks. I like working on crazy and unconventional ideas, enjoy talking about entrepreneurship and leadership, debate about science and technology, watching Marvel movies and series. If you do any of these or otherwise, then don't hesitate to say hi and talk to me :)