Skip to content

Countries Without Postal Codes

Some countries do not have postal code systems. When shipping to these destinations or validating addresses, you may need to detect this and provide a fallback value.

Use the Country helper to check if a country uses postal codes:

use Cline\PostalCode\Support\Country;
// Countries with postal codes
Country::hasPostalCode('US'); // true
Country::hasPostalCode('GB'); // true
Country::hasPostalCode('DE'); // true
// Countries without postal codes
Country::hasPostalCode('HK'); // false (Hong Kong)
Country::hasPostalCode('AE'); // false (United Arab Emirates)
Country::hasPostalCode('QA'); // false (Qatar)

The method is case-insensitive:

Country::hasPostalCode('hk'); // false
Country::hasPostalCode('Hk'); // false

When a country doesn’t use postal codes but your system requires one (e.g., for shipping carriers), use the fallback:

use Cline\PostalCode\Support\Country;
$postalCode = Country::hasPostalCode($countryCode)
? $userProvidedPostalCode
: Country::fallbackPostalCode(); // Returns '00000'

Here’s how to normalize postal codes in a shipping application:

use Cline\PostalCode\Facades\PostalCode;
use Cline\PostalCode\Support\Country;
function normalizePostalCode(string $postalCode, string $countryCode): string
{
// Countries without postal codes get the fallback
if (!Country::hasPostalCode($countryCode)) {
return Country::fallbackPostalCode();
}
// Format valid postal codes, return original if invalid
return PostalCode::for($postalCode, $countryCode)->formatOr($postalCode);
}
// Usage
normalizePostalCode('90210', 'US'); // '90210'
normalizePostalCode('WC2E9RZ', 'GB'); // 'WC2E 9RZ'
normalizePostalCode('anything', 'HK'); // '00000'
normalizePostalCode('anything', 'QA'); // '00000'

Get all countries without postal code systems:

use Cline\PostalCode\Support\Country;
$countries = Country::countriesWithoutPostalCodes();
// ['AE', 'AG', 'AN', 'AO', 'AW', 'BF', 'BI', ...]
CodeCountry
AEUnited Arab Emirates
AGAntigua and Barbuda
ANNetherlands Antilles (former)
AOAngola
AWAruba
BFBurkina Faso
BIBurundi
BJBenin
BOBolivia
BSBahamas
BWBotswana
BZBelize
CDDemocratic Republic of the Congo
CFCentral African Republic
CGRepublic of the Congo
CIIvory Coast
CKCook Islands
CMCameroon
CWCuracao
DJDjibouti
DMDominica
EREritrea
FJFiji
GAGabon
GDGrenada
GHGhana
GMGambia
GQEquatorial Guinea
GYGuyana
HKHong Kong
JMJamaica
KIKiribati
KMComoros
KNSaint Kitts and Nevis
KPNorth Korea
MLMali
MOMacau
MRMauritania
MWMalawi
NRNauru
NUNiue
QAQatar
RWRwanda
SBSolomon Islands
SCSeychelles
SLSierra Leone
SOSomalia
SRSuriname
SSSouth Sudan
STSao Tome and Principe
SXSint Maarten
SYSyria
TDChad
TGTogo
TKTokelau
TLTimor-Leste
TOTonga
TVTuvalu
UGUganda
VUVanuatu
YEYemen
ZWZimbabwe