Metadata-Version: 2.4
Name: ironclad
Version: 0.1.0
Summary: Runtime contracts and predicate-based validation for Python.
Project-URL: Homepage, https://github.com/zentiph/ironclad
Project-URL: Repository, https://github.com/zentiph/ironclad
Project-URL: Issues, https://github.com/zentiph/ironclad/issues
Project-URL: Documentation, https://zentiph.github.io/ironclad
Project-URL: Changelog, https://github.com/zentiph/ironclad/blob/main/CHANGELOG.md
Author-email: "Zentiph (Gavin Borne)" <zentiphdev@gmail.com>
License: Copyright 2025-present Zentiph
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License-File: LICENSE.md
Keywords: contracts,predicates,runtime,types,validation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.11
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: mkdocs; extra == 'dev'
Requires-Dist: mkdocs-material; extra == 'dev'
Requires-Dist: mkdocstrings[python]; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pygments; extra == 'dev'
Requires-Dist: pymdown-extensions; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown

# ironclad
**ironclad** helps developers write defensive, self-documenting Python code.

It enforces parameter types, constrains values with predicates or enums,
and raises precise errors on violation—keeping interfaces explicit and code clean.
Simple, composable guards harden functions and classes with correctness and security,
with minimal overhead and maximum readability.

[![GitHub License](https://img.shields.io/github/license/zentiph/ironclad?style=flat-square&labelColor=0f0f0f)](https://github.com/Zentiph/ironclad/blob/main/LICENSE.md)
[![Contributors](https://img.shields.io/github/contributors/zentiph/ironclad?style=flat-square&labelColor=0f0f0f)](../../graphs/contributors)
<br/>
[![GitHub commit activity](https://img.shields.io/github/commit-activity/t/zentiph/ironclad?style=flat-square&labelColor=0f0f0f)](https://github.com/zentiph/ironclad/commits/main)
[![Last Commit](https://img.shields.io/github/last-commit/zentiph/ironclad?style=flat-square&labelColor=0f0f0f)](https://github.com/zentiph/ironclad/commits/main)
<br/>
![Code Style: Ruff](https://img.shields.io/badge/code%20style-Ruff-d7ff64?style=flat-square&labelColor=0f0f0f)
![Linter: Ruff](https://img.shields.io/badge/linter-Ruff-d7ff64?style=flat-square&labelColor=0f0f0f)

## Features
* **Strict type checks:** Fail fast on mismatches with clear `TypeError`s.
* **Value constraints:** Allowlists, enums, ranges, and custom predicates.
* **Composable guards:** Combine checks for rich, readable contracts.
* **Low-boilerplate API:** Keep validation close to the signature, not scattered.
* **Security-minded:** Reduce attack surface from unexpected inputs.

## Installation
You can install **ironclad** in one of two ways:
1. Install via pip:
```bash
pip install ironclad
```
2. Clone this repository:
```bash
git clone https://github.com/Zentiph/ironclad
```

## Quick Start
### Importing the library:
```python
>>> import ironclad as ic
```
### Ensuring strict type enforcements on functions:
```python
>>> # enforcing types with instance/type spec checks
>>> @ic.enforce_types(price=float, tax_rate=float)
... def add_sales_tax(price, tax_rate):
...     return price * (1 + tax_rate)
...
>>> add_sales_tax(50.0, 0.08)
54.0
>>> add_sales_tax(50.0, "0.08")
TypeError: add_sales_tax(): 'tax_rate' expected 'float', got 'str' with value '0.08'
>>>
>>> # enforcing types with type annotations
>>> @ic.enforce_annotations()
... def get_even(l: list[int]) -> list[int]:
...     return [e for e in l if e % 2 == 0]
...
>>> get_even([1, 2, 3])
[2]
>>> get_even([1.0, 2.0, 3.0])
TypeError: get_even(): 'l' expected 'list[int]', got 'list' with value [1.0, 2.0, 3.0]
```
### Creating type-enforced runtime overloads:
```python
>>> @ic.runtime_overload
... def describe(x: int):
...     return f"int: {x}"
...
>>> @describe.overload
... def _(x: str):
...     return f"str: '{x}'"
...
>>> describe(1)
'int: 1'
>>> describe("hi")
"str: 'hi'"
>>> describe(2.3)
InvalidOverloadError: No overload of describe() matches (float). Candidates: describe(x: int) | describe(x: str)
```
### Creating predicates
```python
>>> is_pos = ic.predicates.Predicate[int](
...     lambda x: x > 0, "is positive"
... )
>>> is_pos(4)
True
>>> is_pos(-1)
False
```

## Documentation
ironclad's documentation is [deployed on GitHub Pages](https://zentiph.github.io/ironclad/).

## Contributions
See [the contributing page](CONTRIBUTING.md).

## License
See [the license page](LICENSE.md).