iron-monk
Business constraint validation for people who hate data mutation.
The fastest Pure-Python validator. 0.06MB. 0 Dependencies. 100% Type-Safe.
📖 Read the official documentation here: benesgarage.github.io/iron-monk
Installation
Install via your preferred package manager:
# Using pip
pip install iron-monk
# Using uv
uv add iron-monk
# Using poetry
poetry add iron-monk
iron-monkuses themonknamespace. Alwaysimport monkin your code.
Quickstart
from typing import Annotated
from monk import monk, validate
from monk.constraints import Email, Interval
@monk
class User:
# No base class, no magic. Just your data.
email: Annotated[str, Email]
age: Annotated[int, Interval(ge=18)]
user = User(email="not-an-email", age=12)
validate(user) # Captures BOTH email and age errors; doesn't fail-fast.
When validation fails, iron-monk aggregates all errors into structured dictionaries.
from monk import validate
from monk.exceptions import ValidationError
try:
validate(user)
except ValidationError as e:
print(e.errors)
# [{'field': 'email', 'message': 'Must be a valid email address.', 'code': 'Email'}, ...]
print(e.flatten())
# ['email: Must be a valid email address.', 'age: Must be greater than or equal to 18.']
The Toolkit
Batteries included. iron-monk comes with a comprehensive suite of built-in constraints, handling complex strings that other libraries ignore:
- 📝
CSV: Deeply validate comma-separated strings in-place without allocating lists in memory. - ☁️
Cron: Structurally validate standard POSIX and strict AWS EventBridge scheduling strings. - 🔒
JWT: Verify JSON Web Tokens structurally before passing them to heavy cryptography libraries. - 📜
JSON: Ensure a string contains valid, parsable JSON without mutating it into a dictionary. - 🔀
Not: Seamlessly invert the logic of any constraint (e.g.,Not(URL)).
👉 Check out the Constraint Toolkit →
Performance
iron-monk doesn't compromise on speed.
Tested on Python 3.13, executing 100,000 simple primitive validations.
| Metric | iron-monk(v0.18.2) |
msgspec(v0.18.6) |
pydantic(v2.10.6) |
attrs(v24.3.0) |
marshmallow(v3.26.1) |
|---|---|---|---|---|---|
| Package Size | 0.06 MB |
0.44 MB |
5.91 MB |
0.21 MB |
0.17 MB |
| Cold Start | 44.77ms |
52.62ms |
83.46ms |
55.73ms |
56.01ms |
| Object (100k) | 0.185s |
0.014s |
0.060s |
0.089s |
N/A |
| Dict (100k) | 0.067s |
0.059s |
0.057s |
N/A | 0.445s |
| Nested Dict (100k) | 0.280s |
0.075s |
0.062s |
N/A | 1.513s |
| Invalid Dict (100k) | 0.244s |
0.091s |
0.088s |
N/A | 1.117s |
| Sanitized Dict (100k) | 0.083s |
0.070s |
0.058s |
N/A | 0.450s |
| Partial Dict (100k) | 0.056s |
N/A | N/A | N/A | 0.293s |
| Function Call (100k) | 0.162s |
N/A | 0.065s |
N/A | N/A |
The Takeaway: While Rust-backed libraries win on raw loop speed, iron-monk is the most efficient choice for the modern cloud. With a footprint 100x smaller than Pydantic and significantly faster cold starts, it is the best-in-class validator for AWS Lambda, serverless environments, and CI/CD pipelines where install time and memory overhead are the real bottlenecks.
👉 See our benchmarking methodology →
Why iron-monk?
Most validation libraries do too much. They don't just check your data; they change it. iron-monk is different:
- ❌ No Coercion: We won't "helpfully" turn your string "123" into an integer. If it's the wrong format, it's an error. Period.
- ❌ No Base Classes: Stop inheriting from BaseModel. Keep your classes clean and your IDE's autocompletion fast.
- ❌ No Compilation: Pure Python. No gcc or Rust toolchains required. It just works, everywhere.
- ❌ No Side Effects: Validating an object should never mutate its state. We keep your data exactly as you provided it.
Real-world examples
iron-monk is designed to drop into any modern Python project. Some notable projects include:
- 🍓 Strawberry GraphQL:
iron-monkhelps validateinputobjects seamlessly. - ⚡ Starlette (ASGI): HTTP endpoints with simple request validation using
iron-monk. - 🖥️ tyro (CLI tool): Generate command-line interfaces from dataclasses and validate with
iron-monk.
👉 See iron-monk integrate with these projects, and more →
📚 Documentation
Ready to go deeper? Explore our guides:
- Core Concepts: Understand the validation lifecycle and error extraction.
- Advanced Usage: Multi-field validation and custom error messages.
- Custom Constraints: Learn how to build your own reusable constraints in 3 lines of code.
License
MIT
Metadata
Release files for iron-monk 0.19.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| iron_monk-0.19.2.tar.gz | 35.0 kB | With provenance | Details for iron_monk-0.19.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iron_monk-0.19.2-py3-none-any.whl | Python 3 | none | any | Details for iron_monk-0.19.2-py3-none-any.whl |
Total release size: 56.6 kB
Release files / iron_monk-0.19.2.tar.gz
| Download URL | iron_monk-0.19.2.tar.gz |
|---|---|
| Size | 35.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f0bdac9fe87fb166483836311ed0ac2c3e3b50ae9bd47ff33c4a7003f9367f0
|
|
BLAKE2b-256 checksum How to use checksums |
12fdd64d53b8f1cd1e1151385d3f733ed3f8bc433cd620d9f0b5e0f565400eff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.
Transparency logRelease files / iron_monk-0.19.2-py3-none-any.whl
| Download URL | iron_monk-0.19.2-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
194ac040c8ee65d6d0b86f33e9b7ba9dd9263e20737c44b98e1a579facfb8edd
|
|
BLAKE2b-256 checksum How to use checksums |
6e4649b3d2d2d5060141abb1f7988c67d815791d9d4928d414929b01c41e1c91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.
Transparency logSecurity for iron-monk 0.19.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for iron_monk-0.19.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.