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.1.tar.gz (65.1 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.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: airform-0.2.1.tar.gz
  • Upload date:
  • Size: 65.1 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.1.tar.gz
Algorithm Hash digest
SHA256 cfb763913333fdd0386d0049864d86e4502311b9fec35846790a5c095182102c
MD5 e1efde8e0c8c0db4d9f5fb49e5aa6f3f
BLAKE2b-256 47f6b107f9371a0d790d9e4322c00062847418d65e09887fcc21d5a8ec4e71a5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: airform-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8050908dfa719bee7b7fb3fe6ee43b7ad528ca513f12e98f8202a64443e3e6a
MD5 a23a2630d282ecf1d4a891188d969862
BLAKE2b-256 10c99ed5a56d79725106136430670cfc58e84e2d25b358888598847c95cdf5b6

See more details on using hashes here.

Provenance

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