Zod-inspired dict validation for Python. Zero deps. One file.
Project description
zodify
Zod-inspired dict validation for Python. Zero deps. One file.
Note: zodify is in alpha. The API is minimal and may change. Feedback and contributions are welcome!
Quick Start
from zodify import validate
config = validate(
{"port": int, "debug": bool},
{"port": 8080, "debug": True},
)
That's it. Plain dicts in, validated dicts out. No classes, no DSL, no dependencies.
Why zodify?
Most validation libraries ask you to learn a new DSL or model system. zodify doesn't.
| zodify | zon | zodic | Pydantic | |
|---|---|---|---|---|
| Philosophy | Minimalist | Full Zod port | Full Zod port | Full ORM |
| API style | Plain dicts | Chained builders | Chained builders | Classes |
| Dependencies | 0 | 2 | 0 | Many |
| Code size | <200 LOC | 1,000s+ LOC | 1,000s+ LOC | Large |
| Learning curve | Zero | Must learn DSL | Must learn DSL | Must learn DSL |
| Env var support | Built-in | No | No | Partial |
Install
pip install zodify
Requires Python 3.10+
To install from source:
git clone https://github.com/junyoung2015/zodify.git && pip install ./zodify
Usage
validate() — Dict Schema Validation
Define a schema as a plain dict of key: type pairs, then validate any dict against it.
from zodify import validate
schema = {"port": int, "debug": bool, "name": str}
# Exact type match
result = validate(schema, {"port": 8080, "debug": True, "name": "myapp"})
# → {"port": 8080, "debug": True, "name": "myapp"}
# Coerce strings — great for env vars and config files
raw = {"port": "8080", "debug": "true", "name": "myapp"}
result = validate(schema, raw, coerce=True)
# → {"port": 8080, "debug": True, "name": "myapp"}
# All errors are collected at once
validate({"a": int, "b": str}, {"a": "x", "b": 42})
# ValueError: a: expected int, got str
# b: expected str, got int
Parameters:
| Param | Type | Default | Description |
|---|---|---|---|
schema |
dict |
— | Mapping of keys to expected types (str, int, ...) |
data |
dict |
— | The dict to validate |
coerce |
bool |
False |
Cast string values to the target type when possible |
Behavior:
- Extra keys in
dataare silently stripped — only schema-declared keys are returned. - Missing keys raise
ValueError. - When
coerce=True, onlystrinputs are coerced (non-string mismatches still error). - Bool coercion accepts:
true/false,1/0,yes/no(case-insensitive).
env() — Typed Environment Variables
Read and type-cast environment variables with a single call.
from zodify import env
port = env("PORT", int, default=3000)
debug = env("DEBUG", bool, default=False)
secret = env("SECRET_KEY", str) # raises ValueError if missing
Parameters:
| Param | Type | Default | Description |
|---|---|---|---|
name |
str |
— | Environment variable name |
cast |
type |
— | Target type (str, int, float, bool) |
default |
any | (none) | Fallback if the var is unset. Not type-checked. |
from zodify import count_in_list
count_in_list(["a", "b", "a", "c"], "a") # → 2
Roadmap
zodify is in alpha (v0.0.1). The API surface is small and may evolve.
Near-term:
- Nested schema validation
- Optional / nullable fields
- Custom validator functions
- List item validation
Exploring:
-
.envfile loading - JSON Schema export
- Framework integrations (FastAPI, Django)
- Async validation support
- Chained builder API
License
MIT — 2026 Jun Young Sohn
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zodify-0.0.1.tar.gz.
File metadata
- Download URL: zodify-0.0.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b64ec16a5624e7acf99e5aef4fd4ac2a6e8bb7bf116df87a45a9df2d819a307
|
|
| MD5 |
fc15eca39cf914f898a1f1b2fac615f2
|
|
| BLAKE2b-256 |
e34604b724dd57dc241750fad91a9dc1ab92f1c396beed6fef972fe0af3e47e2
|
File details
Details for the file zodify-0.0.1-py3-none-any.whl.
File metadata
- Download URL: zodify-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
841c594c092cc51e0cd89cdc41e352f90a0596d3e7d032d710232b6690a52a28
|
|
| MD5 |
eca1efb7c7f8dfae3848ac02b14cbb3b
|
|
| BLAKE2b-256 |
961076b4cdadfdb14f5bfdc534347579415addb278d000d78365157c71e37aa2
|