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
Quickstart
Define your models using the @monk decorator and wrap your types in Annotated constraints.
from typing import Annotated
from monk import monk, validate
from monk.constraints import Email, Interval
from monk.exceptions import ValidationError
@monk
class User:
email: Annotated[str, Email]
age: Annotated[int, Interval(ge=18)]
user = User(email="bad-email", age=12)
print(user.email) # Raises UnvalidatedAccessError
try:
validate(user)
except ValidationError as e:
print(e.errors) # [{'field': 'email', 'message': "..."}, {'field': 'age', 'message': "..."}]
user.email = "test@domain.com"
user.age = 25
validate(user)
print(user.email) # "test@domain.com"
Core Philosophy
The Python ecosystem is dominated by heavy validation frameworks. iron-monk is built for a completely different philosophy:
- 🎯 Do one thing well. Unlike libraries that parse, coerce, and serialize,
iron-monkfocuses strictly on validation. - 🪶 Zero Dependencies: Pure Python, 0 dependencies.
- 🧬 Zero Inheritance: No massive base classes polluting your namespace, just decorate a class with
@monk. - 🛡️ Strict: We don't secretly coerce the string
"123"into the integer123. - ⏳ Deferred Validation:
iron-monkcaptures data in a guarded state, giving you control over when validation occurs.
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-monkintegrate with these projects, and more, here!
The Toolkit
Batteries included. iron-monk comes with a suite of built-in constraints:
from typing import Annotated
from monk import monk
from monk.constraints import Each, LowerCase, Len, Interval
@monk
class ComplexModel:
# Validate every item in an iterable
tags: Annotated[list[str], Each(LowerCase, Len(min_len=3))]
# Custom error messages with dynamic interpolation
age: Annotated[int, Interval(ge=18, message="You are {value}, but must be at least {ge}!")]
# Infinitely nestable models with perfectly resolved dot-notation error paths
configs: list[ServerConfig]
You can see the full list of constraints here
Advanced Usage
iron-monk provides powerful tools for complex validation scenarios. Check out the Advanced Usage guide to learn about:
- 🔄 The Lifecycle: Understand the Guarded state of a
monkobject. - ⚡ Fail-Fast Mode: Prefer to crash instantly? Enable Fail-Fast mode globally or per-class.
- 💬 Custom Error Messages: Override default error strings with dynamic interpolation.
- 🤝 Cross-Field Validation: Validate multiple fields together natively.
- 🛠️ Custom Constraints: Build your own rules using pure duck-typing and standard exceptions.
License
MIT
Metadata
Release files for iron-monk 0.3.0
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.3.0.tar.gz | 17.9 kB | With provenance | Details for iron_monk-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iron_monk-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for iron_monk-0.3.0-py3-none-any.whl |
Total release size: 30.7 kB
Release files / iron_monk-0.3.0.tar.gz
| Download URL | iron_monk-0.3.0.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1180e6d7f2500f090ce5d20eb09326e2cf0b28adccd816335c73e27c670ee9a
|
|
BLAKE2b-256 checksum How to use checksums |
4d4f9422515c4339313e25a1482f004c8ac5ec761fa923956153e604f923c46b
|
| 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 Mar 20, 2026.
Transparency logRelease files / iron_monk-0.3.0-py3-none-any.whl
| Download URL | iron_monk-0.3.0-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d360ffcfc916cf6a4850b065ef210cd72fa9bbdd51c5e4b8c34a33e54b3a4a9a
|
|
BLAKE2b-256 checksum How to use checksums |
130cb5343f1ef3f61ce494332cf9baf14502bf455967e90c4ce23ca9b9f6da47
|
| 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 Mar 20, 2026.
Transparency logSecurity for iron-monk 0.3.0
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.3.0.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 Mar 20, 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.