Data Science

Pydantic – data validation using Python type hints

Pydantic is a data validation library for Python.

Define how data should be in pure, canonical Python 3.7+; validate it with Pydantic.

This is free and open source software.

Key Features

  • Type hints powering schema validation. The schema that Pydantic validates against is generally defined by Python type hints.
  • Core validation logic is implemented in separate package pydantic-core, where validation for most types is implemented in Rust.
  • Provides functionality to serialize model in three ways:
    • To a Python dict made up of the associated Python objects.
    • To a Python dict made up only of “jsonable” types.
    • To a JSON string.
  • JSON Schema can be generated for any Pydantic schema — allowing self-documenting APIs and integration with a wide variety of tools which support JSON Schema.
  • Strict mode and data coercion.
  • Provides four ways to create schemas and perform validation and serialization:
    • BaseModel — Pydantic’s own super class with many common utilities available via instance methods.
    • pydantic.dataclasses.dataclass – a wrapper around standard dataclasses which performs validation when a dataclass is initialized.
    • TypeAdapter – a general way to adapt any type for validation and serialization. This allows types like TypedDict and NampedTuple to be validated as well as simple scalar values like int or timedelta – all types supported can be used with TypeAdapter.
    • validate_call – a decorator to perform validation when calling a function.
  • Customisation

Website: docs.pydantic.dev/latest
Support: GitHub Code Repository
Developer: Pydantic Services Inc. and individual contributors
License: MIT License

Pydantic is written in Python. Learn Python with our recommended free books and free tutorials.


Related Software

Python Data Validation
PydanticData validation using Python type hints
panderaFramework for precision data testing
jsonschema
Implementation of JSON Schema for Python
CerberusLightweight and extensible data validation library
schemaLibrary for validating Python data structures
GXValidating, documenting, and profiling data
marshmallowORM/ODM/framework-agnostic library
VoluptuousPython data validation library
SchematicsCombine types into structures, validate , and transform the shapes of data
ColanderSerialization / deserialization / validation library
ValideerLightweight data validation and adaptation Python library
OpenRefineDesktop program for data cleanup and transformation
Soda CoreData quality and data contract verification engine
OpenMetadataUnified metadata platform
Elementary OSS dbt-native data observability command-line tool

Read our verdict in the software roundup.


Best Free and Open Source Software Explore our comprehensive directory of recommended free and open source software. Our carefully curated collection spans every major software category.

This directory is part of our ongoing series of informative articles for Linux enthusiasts. It features hundreds of detailed reviews, along with open source alternatives to proprietary solutions from major corporations such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk.

You’ll also find interesting projects to try, hardware coverage, free programming books and tutorials, and much more.

Discovered a useful open source Linux program that we haven’t covered yet? Let us know by completing this form.