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.3.0.tar.gz (68.3 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.3.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for airform-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7c64e759fd3b7be895a68e347ca1579e3e36cc12aa76fa2528332c66ddab6659
MD5 8c4ee1f6047f4060cee9acad1608b1bd
BLAKE2b-256 5d2a349bd9eb38a8de8ce83e5d83ba04feccc7728322a32ab92aeecbe93ca2f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for airform-0.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: airform-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00824b875592aae832a6283ecb82ea45af92edbcd2a71dbbd1fa4621f9b6684c
MD5 05f59efece220411bf5d7d44a11433bf
BLAKE2b-256 deacbce59fc699b27796ee9b5ab25b731b22f62035f59da0cdaf2d5fedcab351

See more details on using hashes here.

Provenance

The following attestation bundles were made for airform-0.3.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