Skip to main content

Human-readable error messages for Pydantic validation errors.

Project description

pydantic-explain

Human-readable error messages for Pydantic validation errors.

Installation

With uv:

uv add pydantic-explain

Usage

from pydantic import BaseModel, ValidationError
from pydantic_explain import format_errors


class Address(BaseModel):
    street: str
    zipcode: str


class User(BaseModel):
    name: str
    addresses: list[Address]


try:
    User.model_validate({
        "name": "Alice",
        "addresses": [
            {"street": "123 Main St"},
            {"street": "456 Oak Ave", "zipcode": ["invalid"]},
        ],
    })
except ValidationError as e:
    print(format_errors(e))
Validation failed for User with 2 errors

  addresses[0].zipcode
    Field required
    Got: (missing)

  addresses[1].zipcode
    Input should be a valid string
    Got: ['invalid']

Documentation

Full documentation is available at pydantic-explain docs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_explain-0.0.1a0.tar.gz (61.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_explain-0.0.1a0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_explain-0.0.1a0.tar.gz.

File metadata

  • Download URL: pydantic_explain-0.0.1a0.tar.gz
  • Upload date:
  • Size: 61.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pydantic_explain-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 0f61def42c257391b8fd84a0621de76ab52779a3924e9c713231ceeeec85052b
MD5 ce1ac442da915d0c773dddf38a2b471c
BLAKE2b-256 d2c4e27f456c376e88bc931891528e9bb06265a6e5318866e5fafb983ab47e11

See more details on using hashes here.

File details

Details for the file pydantic_explain-0.0.1a0-py3-none-any.whl.

File metadata

  • Download URL: pydantic_explain-0.0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pydantic_explain-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7bf33f8fb071a95fa9a5cea8f729d910efa4f9ecf95de3f2f2c42c06e3bf2b8
MD5 6211700c68e3bd2776ac627e114e158f
BLAKE2b-256 6377a3a35212a2b1ab7c945560197f2d41ad3b5cd1d749d7dac566719775a934

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page