UI Experiment · 2026

Country-Aware Address Form

A data-driven global address form. Pick any country and the fields, labels, order, subdivision list, and postal format reconfigure from a per-country config. Validation runs locally and deterministically; Claude review is an optional second opinion, not the gatekeeper.

What changed: address entry stopped silently losing data. Every country's format is handled by configuration, so supporting a new country is a table row, not new code.

Forms & Validation Global Addresses Deterministic Validation JavaScript Claude Review (optional)

Overview

What I Built

International address collection looks simple until you build it properly. The United States uses city, state, and ZIP code; the United Kingdom uses town, county, and postcode; Japan reverses the whole hierarchy and leads with the postal code. A single static form fails all of them, and forcing every country into a US-shaped form silently loses data.

This rebuild is data-driven instead of conditional. A per-country config table drives everything: which fields appear, what they are labeled, the order they render in, whether the subdivision is a dropdown or free text, whether it is required, and the postal code label, pattern, and example. The form has no country-specific if statements in its render path. Adding a country means adding a row to the table, and every country in the list reconfigures the form, including the ones with no special rules.

Validation follows the same principle. It runs locally, on blur and on submit, against the config: required fields, subdivision membership, and postal patterns. A live mailing-label preview shows the address laid out the way that country writes it, so a formatting mistake is visible before anything is submitted. Claude review is still available, but as an optional second step that suggests real-world corrections, not as the thing standing between the user and a valid address. No paid address API, no new service, no uncapped billing.

The rule

The form never guesses. Every rule comes from the config table.

If a rule cannot be stated as data for a country, it does not belong in the form. That is what keeps 193 countries consistent instead of 193 special cases.

Try It

Global Address Form

Pick a country and watch the form reconfigure, or load a preset to see a complete valid address instantly. Validate locally, check the mailing-label preview, then optionally ask Claude for a second opinion.

Core validation runs entirely in your browser. The optional Claude review is routed through a Cloudflare Worker proxy; the Anthropic API key is stored as a Worker secret and never exposed client-side. No address data is stored or logged anywhere.
Presets:
Pick a country, fill in the address, and validate. The mailing-label preview updates as you type.

Mailing-label preview

Select a country to begin.

Architecture

How It Works

The form is a small rendering engine over a data table. Nothing about any specific country lives in the render code, which is why the same code path serves a US ZIP code and a Japanese postal code without branching.

Why keep the AI out of the gate? A language model can suggest a better address, but it can also hallucinate a confident correction to a valid one. Deterministic checks never do. So the model advises and the config decides, which is also what keeps the demo free to run: no paid address API, no per-validation billing, no uncapped usage.

Reflection

What I Learned

Rebuilding the demo around a config table changed what I thought the hard parts were:

Tools Used

Tech Stack

Built without frameworks or build tools: vanilla JavaScript, a country config table, and an optional Claude review.

Vanilla JavaScript (ES2022+) Country Config Data Postal Patterns Deterministic Validation Claude Sonnet (optional review) Anthropic Messages API HTML / CSS Cloudflare Workers

Keep exploring

Head back to the projects page.