Installation
pip install iron-monk
uv add iron-monk
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
- Fail-Fast Mode: Prefer to fail fast on instatiation? Set fail-fast per class, or globally!
- Custom Constraints: Building your own constraints is stupidly simple thanks to duck-typing. Just write a class with a
validate(self, field, value)method that raises aValueError. Use our@constraintwrapper to automatically get custom error message interpolation!
Want to know more, see here!
License
MIT
Metadata
Release files for iron-monk 0.2.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.2.0.tar.gz | 16.1 kB | With provenance | Details for iron_monk-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iron_monk-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for iron_monk-0.2.0-py3-none-any.whl |
Total release size: 28.0 kB
Release files / iron_monk-0.2.0.tar.gz
| Download URL | iron_monk-0.2.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96aea54dfaf8390e874b7daab47a00b0e16d4c60579a9dc77f7699803935ecc9
|
|
BLAKE2b-256 checksum How to use checksums |
81ad3f2439c310fdf9b4e465624e38f1ca5d2a20466e5c67d4612e64d25bc9dc
|
| 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 18, 2026.
Transparency logRelease files / iron_monk-0.2.0-py3-none-any.whl
| Download URL | iron_monk-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2648fce576a39ddc49d00e809ec41113732bc5312ab70935764708f06f79bd7
|
|
BLAKE2b-256 checksum How to use checksums |
49e11409b3f336d163a8dda6fc9e03279fe1d5cd4a6732726e6de85bc56f00fa
|
| 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 18, 2026.
Transparency logSecurity for iron-monk 0.2.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.2.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 18, 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.