Larz › Typed request validation in Python

Typed validation, straight from the signature

Annotate your handler's parameters; Larz validates, coerces and injects them — the ergonomics of FastAPI/Pydantic, with zero dependencies.

pip install larz
@app.post("/items")
def create(req, name: str, qty: int = 1, active: bool = True):
    return {"name": name, "qty": qty}     # coerced; missing 'name' -> 422

QuickstartGitHubDocs

Dataclass bodies

from dataclasses import dataclass
@dataclass
class Order:
    product: str
    price: float
    qty: int = 1

@app.post("/order")
def order(req, o: Order):                  # whole JSON body -> validated Order
    return {"total": o.price * o.qty}

Invalid input returns a 422 with per-field errors. Values come from the JSON body, form or query as appropriate; Query, Path, Body and Form markers let you be explicit. No schema classes, no third-party library.

FAQ

Does Larz use Pydantic?

No — typed validation is built on the standard library's typing and dataclasses. Larz stays zero-dependency.

What happens on invalid input?

Larz returns a 422 with a per-field error map before your handler runs; valid values are coerced to the annotated types and injected.