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.2.tar.gz (17.4 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.2-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dictify-5.0.2.tar.gz
  • Upload date:
  • Size: 17.4 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.2.tar.gz
Algorithm Hash digest
SHA256 29a41c4eb06a3c08ff71795405b926494261f61646452739e597d781652ee718
MD5 e580d8f9ee82838cf9af1458b5470d03
BLAKE2b-256 7de8d753b6e8297dbe9523852e6e871c23c310bbd31b7378597d56229a0b3c79

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dictify-5.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 215c57a98cb2e0ddd6966ed8e2a8f035abcbd2f359aed723cda5e7e3b11686a3
MD5 39030b4f91335410021db0a517932a20
BLAKE2b-256 df6f6c41a8dc761df3104370508d5c8e1f5eaf42b35568a66ac66b5bb087135b

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