Skip to main content

Documents schema and data validation

Project description

Dictify

Lightweight validation for Python mappings and JSON-like documents.

Dictify provides standalone field validation and annotation-first Model classes for dict-shaped data. It keeps mapping access and attribute access together, validates assignments, supports strict or permissive unknown-key handling, and converts models back to plain Python data.

  • Python 3.11+
  • Field(...) for defaults, required fields, and validators
  • Model for mapping-shaped schemas
  • dict(model) for shallow conversion, model.dict() for recursive conversion
  • Inspectable model signatures for CLI/data-binding tools such as Cyclopts

Install

pip install dictify

Example

from datetime import UTC, datetime
from typing import Annotated

from dictify import Field, Model


class Note(Model):
    title: Annotated[
        str,
        Field(required=True).verify(
            lambda value: len(value) <= 300,
            "Title must be 300 characters or fewer",
        ),
    ]
    content: Annotated[str, Field()]
    timestamp: Annotated[datetime, Field(default=lambda: datetime.now(UTC))]


note = Note(title="Dictify", content="dictify is easy")

note.content = "Updated content"
note["content"] = "Updated again"

assert note["content"] == "Updated again"
assert isinstance(note.dict()["timestamp"], datetime)

Model is strict by default. Pass _strict=False to keep undeclared keys as extra model data:

note = Note({"title": "Dictify"}, _strict=False)
note.category = "docs"

assert note["category"] == "docs"

Standalone fields work without a model:

email = Field(required=True).instance(str).match(r".+@.+")
email.value = "user@example.com"

AI Skill

Dictify ships with an optional packaged AI skill installer:

dictify ai-skill-install

Development

Repository-local maintenance commands live under dev/cli:

uv run python -m dev.cli --help
uv run python -m dev.cli release-check

See dev/README.md for the command summary and release workflow.

Documentation

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

dictify-5.0.1.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

dictify-5.0.1-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file dictify-5.0.1.tar.gz.

File metadata

  • Download URL: dictify-5.0.1.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dictify-5.0.1.tar.gz
Algorithm Hash digest
SHA256 cdbe0c3109a4319980ec525d62c68b3534500ed4ce307e34befac33105ab646f
MD5 0a4895fb8477bb1421814b8246fe8500
BLAKE2b-256 3e2a1d9cb835d419324b9535ad2256639024b7591ce416afac834ebd28d0cb41

See more details on using hashes here.

File details

Details for the file dictify-5.0.1-py3-none-any.whl.

File metadata

  • Download URL: dictify-5.0.1-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dictify-5.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dd6328b37c77b6a6e4de8d3a62113487933a7640ed1b667b50621014d29cf736
MD5 b837bf5e1e9ce90a3122c0529a20e4f8
BLAKE2b-256 db2f785bd152a548df3b7e4968f08b59acf4f96a94951b24036a14c9cce18895

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