What Makes an Address 'Valid'? Address Components Explained
Learn what makes a mailing address valid. Understand required components, formatting rules, and how validation differs between countries.
Defining a "Valid" Address
An address can be "valid" in three different senses, and confusing them leads to bugs and bad user experiences:
Software validation typically focuses on format and completeness. Only postal service APIs can confirm deliverability.
Required Components by Country
United States
A deliverable US address requires at minimum:
Optional but helpful:
United Kingdom
Optional:
Germany
State is not required for German postal addresses.
Japan
General Rule
Every country with a postal system requires at minimum:
Levels of Validation
Level 1: Presence Check
The simplest validation — are the required fields filled in?
function basicValidation(address) {
if (!address.street) return 'Street address is required';
if (!address.city) return 'City is required';
if (!address.postalCode) return 'Postal code is required';
return null; // Valid
}
This catches empty forms but nothing else.
Level 2: Format Validation
Check that each field matches the expected format:
function formatValidation(address, country) {
const postalPatterns = {
US: /^[0-9]{5}(-[0-9]{4})?$/,
UK: /^[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}$/i,
CA: /^[A-Z][0-9][A-Z]\s?[0-9][A-Z][0-9]$/i,
DE: /^[0-9]{5}$/,
JP: /^[0-9]{3}-[0-9]{4}$/,
};
const pattern = postalPatterns[country];
if (pattern && !pattern.test(address.postalCode)) {
return 'Invalid postal code format';
}
return null;
}
Level 3: Consistency Validation
Check that fields are internally consistent:
Level 4: Deliverability Validation
Use a postal service API or commercial validation service to confirm:
This requires external API calls and is typically done server-side during form submission, not on every keystroke.
Common Validity Problems
Incorrect Postal Code Ranges
Each US state has specific ZIP code ranges. Common mistakes:
Invalid: Los Angeles, CA 10001 (10001 is New York)
Valid: Los Angeles, CA 90001