On this page
enforce-type
Prev: escape-colors | Up: projects | Next: kindof
Rel: wispsy, Foundation, kindof
Ref: wispsy on GitHub
Tags: #public #wispsy #project #foundation #tier/core
Role
Independent pure-Python compiled validation for ordinary type annotations (check, load, dump, load_partial), with Annotated constraints (Min, Max, Length) and opt-in scalar coercion.
Install
python -m pip install enforce-type
Quickstart
from dataclasses import dataclass
from enforce_type import compile_type
@dataclass
class User:
name: str
age: int
active: bool = True
users = compile_type(User)
user = users.load({"name": "Ella", "age": 34})
assert users.check(user) is user
assert users.dump(user) == {"name": "Ella", "age": 34, "active": True}
When to Reach for It
- Validating inputs, configs, or dataclass contracts directly from standard Python 3.14+ type hints with zero runtime dependencies.
- Avoiding model base-class lock-in while getting structured, value-free
ValidationErrorissues.
Gotchas & Pitfalls
- No implicit coercion by default:
checkandloadreject mismatched scalar types unless scalar coercion is explicitly opted into. - Value-free
ValidationErrorissues: Error reports omit raw input values by design to avoid leaking secrets into logs—inspect field paths and constraint codes rather than expecting echoed payloads. - Python 3.14+ annotation semantics: Compiled validators target Python
>=3.14typing andAnnotatedmetadata (Min,Max,Length); exotic runtime metaclasses outside standard annotations are not supported.
Pairs With
- kindof — Typed, JSON-compatible object inspection alongside runtime validation.
- expose-api — Complements typed dataclass API contracts.
Metadata
type: project-card
slug: enforce-type
org: wispsy
repo: wispsy/enforce-type
package: enforce-type
version: 0.2.0
requires_python: ">=3.14"
layer: foundation
topic: wispsy-foundation
status: active
language: python
source_docs: README.md, docs/
Linked from
Related notes
- wiki/projects/escape-colors Linked here; links to this page; shared tags: #foundation, #project, #tier, #wispsy
- wiki/projects/kindof Linked here; links to this page; shared tags: #foundation, #project, #tier, #wispsy
- wiki/projects/expose-api Linked here; links to this page; shared tags: #project, #tier, #wispsy
- wiki/stack/foundation Linked here; links to this page; shared tags: #foundation, #tier, #wispsy
- wiki/projects Linked here; links to this page; shared tags: #wispsy
- wiki/projects/backpack-store links to this page; shared tags: #foundation, #project, #tier, #wispsy
- wiki/projects/apiconn links to this page; shared tags: #project, #tier, #wispsy
- wiki/choosing links to this page; shared tags: #tier, #wispsy
- wiki/compatibility links to this page; shared tags: #tier, #wispsy
- wiki/families links to this page; shared tags: #tier, #wispsy