Skip to main content

Pydantic-native form validation and rendering. Define a model, get a validated, rendered HTML form. Works with or without Air web framework.

Project description

AirForm

PyPI version

Pydantic-native form validation and rendering. Define a model, get a validated, rendered HTML form. Built for Air, also works standalone with FastAPI, Starlette, Litestar, or any ASGI framework.

Features

  • Type-safe validated data via AirForm[MyModel] generic parameter
  • Reads the full AirField metadata vocabulary: Widget, Label, Placeholder, HelpText, Choices, Autofocus, PrimaryKey, Hidden, ReadOnly
  • Auto-skips PrimaryKey and Hidden("form") fields in rendered output
  • HTML5 validation attributes from Pydantic constraints (minlength, maxlength, required)
  • Accessible by default: aria-invalid, aria-describedby, role="alert" on errors
  • Textarea, select, and checkbox rendering from type annotations and metadata
  • Swappable widget for custom renderers
  • from_request() for async ASGI request handling (works with FastAPI Depends)

Quick start

With Air

from air import AirForm, AirModel, AirField
import air

app = air.Air()

class Contact(AirModel):
    name: str
    email: str = AirField(type="email", label="Email Address")

class ContactForm(AirForm[Contact]):
    pass

@app.post("/contact")
async def submit(request: air.Request):
    form = await ContactForm.from_request(request)
    if form.is_valid:
        return air.Html(air.H1(f"Thanks, {form.data.name}!"))
    return air.Html(air.Raw(form.render()))

Standalone (any ASGI framework)

from pydantic import BaseModel
from airform import AirForm

class ContactModel(BaseModel):
    name: str
    email: str

class ContactForm(AirForm[ContactModel]):
    pass

# Validate
form = ContactForm()
form.validate({"name": "Audrey", "email": "audreyfeldroy@example.com"})
if form.is_valid:
    print(form.data.name)  # type-safe: editor knows this is str

# Render
html = ContactForm().render()

Documentation

Documentation is built with Zensical and deployed to GitHub Pages.

API documentation is auto-generated from docstrings using mkdocstrings.

Docs deploy automatically on push to main via GitHub Actions. To enable this, go to your repo's Settings > Pages and set the source to GitHub Actions.

Installation

uv add AirForm

CLI

Preview rendered form HTML from any Pydantic model:

airform myapp.models:ContactModel

Development

See CONTRIBUTING.md for setup instructions.

Author

AirForm was created in 2026 by Audrey M. Roy Greenfeld.

Built with Cookiecutter and the audreyfeldroy/cookiecutter-pypackage project template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airform-0.2.0.tar.gz (64.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

airform-0.2.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file airform-0.2.0.tar.gz.

File metadata

  • Download URL: airform-0.2.0.tar.gz
  • Upload date:
  • Size: 64.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for airform-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b3a8b5516194303dfb80e9a0e604ead2b62c7b47df266333eb26bdde5508018a
MD5 feb0fc6521736ec7e1dc8bfed3a80107
BLAKE2b-256 57ac2f31489f163c99f8c816b8b7e56c0c2c5b301568d47f2663d35c9224f756

See more details on using hashes here.

Provenance

The following attestation bundles were made for airform-0.2.0.tar.gz:

Publisher: publish.yml on feldroy/AirForm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file airform-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: airform-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for airform-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69fb8e5875081351884ecb524b7b597c7e99aa6e39978f59520f28a26fa7384e
MD5 351bc95557f88f598bc063f020f5cb3d
BLAKE2b-256 54126d39814d0328d2354eed114b54507442d0a191375bf6c5982bdfdae5eb7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for airform-0.2.0-py3-none-any.whl:

Publisher: publish.yml on feldroy/AirForm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page