Skip to main content
iron-monk logo

iron-monk

A minimalist, zero-coercion validation library for Python.

PyPI version Python Versions CI/CD Coverage: 100% Zero Dependencies License


📖 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

Quickstart

iron-monk provides four ways to validate your data using constraints.

from typing import Annotated, TypedDict
from monk import monk, validate, validate_dict
from monk.constraints import Email, Interval

@monk
class User:
    email: Annotated[str, Email]
    age: Annotated[int, Interval(ge=18)]

user = User(email="bad-email", age=12)
validate(user) # ❌ ValidationError

@monk
def send_invite(email: Annotated[str, Email]):
    print(f"Sending to {email}")

send_invite("bad-email") # ❌ ValidationError

class UserDict(TypedDict):
    email: Annotated[str, Email]

validate_dict({"email": "bad-email"}, UserDict) # ❌ ValidationError

Email().validate("bad-email") # ❌ ValueError

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.']

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, we focus on validation.
  • 🪶 Zero Dependencies: Pure Python. No compiled binaries or bloated environments.
  • 🛡️ Zero Coercion: We don't secretly cast the string "123" into the integer 123.
  • 🤝 Agnostic to Type Checking: We enforce business constraints, not base Python types.
  • ⏳ Deferred Validation: Capture bad data in a guarded state instead of crashing instantly.
  • 🧬 Zero Inheritance: No massive base classes polluting your namespace. Just a decorator.

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: When evaluating features, execution speed, package size, and cold-start times together, iron-monk is holistically the best-in-class pure-Python validation framework.

👉 See our benchmarking methodology →

Real-world examples

iron-monk is designed to drop into any modern Python project. Some notable projects include:

  • 🍓 Strawberry GraphQL: iron-monk helps validate input objects 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 →

Core Concepts

Understand the validation lifecycle, how to cleanly extract error dictionaries, and how to enforce required fields.

👉 Read the Core Concepts Guide →

The Toolkit

Batteries included. iron-monk comes with a comprehensive suite of built-in constraints. From networking (Email, Port, MacAddress) and formats (HexColor, JSON, SemVer) to collections (Subset, ContainsKeys) and logic (Not, Predicate), you will rarely need to write your own rules.

👉 Check out the Constraint Toolkit →

Advanced Usage

Need to validate multiple fields together, override error messages with string interpolation, or instantly crash on bad data? iron-monk supports complex business logic while maintaining zero magic.

👉 Read the Advanced Usage Guide →

License

MIT

Metadata

Release files for iron-monk 0.18.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iron-monk 0.18.3
File Size Uploaded Provenance Actions
iron_monk-0.18.3.tar.gz 33.7 kB With provenance Details for iron_monk-0.18.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for iron-monk 0.18.3
File Interpreter ABI Platform Actions
iron_monk-0.18.3-py3-none-any.whl Python 3 none any Details for iron_monk-0.18.3-py3-none-any.whl

Total release size: 54.6 kB

Release files / iron_monk-0.18.3.tar.gz

Download URL iron_monk-0.18.3.tar.gz
Size 33.7 kB
Tags Source
SHA-256 checksum
How to use checksums
28cd7d1579d18416ce5759ccc71daee16998fb067af00af9a596e06fc7b8e4e5
BLAKE2b-256 checksum
How to use checksums
bef433af3dddac4536688405ffed4ab674737b920269a7274cc32f383482b5f5
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 28, 2026.

Transparency log

Release files / iron_monk-0.18.3-py3-none-any.whl

Download URL iron_monk-0.18.3-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9694770ffc2efb0f4feb9aba3a163855bffd12ec7e98a106f23aaa8223f7c486
BLAKE2b-256 checksum
How to use checksums
4aca05feae767a1ea6fe259761cd21920451b76f0b908ccbfee9db758b8c3097
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 28, 2026.

Transparency log

Security for iron-monk 0.18.3

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.

Select from 2 files

Attestation for iron_monk-0.18.3.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 28, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.18.3 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page