Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 90 additions & 52 deletions src/postal_regex/data/postal_codes.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,92 @@
[
{"country_code": "IN", "country_name": "India", "postal_code_regex": "^[1-9][0-9]{5}$", "sample_valid": "110001", "sample_invalid": "000000"},
{"country_code": "US", "country_name": "United States", "postal_code_regex": "^[0-9]{5}(?:-[0-9]{4})?$", "sample_valid": "12345-6789", "sample_invalid": "ABCDE"},
{"country_code": "CA", "country_name": "Canada", "postal_code_regex": "^[A-Za-z]\\d[A-Za-z][ -]?\\d[A-Za-z]\\d$", "sample_valid": "K1A 0B1", "sample_invalid": "12345"},
{"country_code": "GB", "country_name": "United Kingdom", "postal_code_regex": "^(GIR 0AA|[A-Z]{1,2}\\d[A-Z\\d]? \\d[ABD-HJLNP-UW-Z]{2})$", "sample_valid": "SW1A 1AA", "sample_invalid": "12345"},
{"country_code": "DE", "country_name": "Germany", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "10115", "sample_invalid": "ABCDE"},
{"country_code": "FR", "country_name": "France", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "75001", "sample_invalid": "1234"},
{"country_code": "IT", "country_name": "Italy", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "00100", "sample_invalid": "ABCDE"},
{"country_code": "ES", "country_name": "Spain", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "28013", "sample_invalid": "1234"},
{"country_code": "AU", "country_name": "Australia", "postal_code_regex": "^[0-9]{4}$", "sample_valid": "2000", "sample_invalid": "12345"},
{"country_code": "BR", "country_name": "Brazil", "postal_code_regex": "^\\d{5}-\\d{3}$", "sample_valid": "01001-000", "sample_invalid": "12345"},
{"country_code": "RU", "country_name": "Russia", "postal_code_regex": "^[0-9]{6}$", "sample_valid": "101000", "sample_invalid": "ABCDE"},
{"country_code": "CN", "country_name": "China", "postal_code_regex": "^[0-9]{6}$", "sample_valid": "100000", "sample_invalid": "12345"},
{"country_code": "JP", "country_name": "Japan", "postal_code_regex": "^\\d{3}-\\d{4}$", "sample_valid": "100-0001", "sample_invalid": "1234567"},
{"country_code": "MX", "country_name": "Mexico", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "01000", "sample_invalid": "ABCDE"},
{"country_code": "ZA", "country_name": "South Africa", "postal_code_regex": "^[0-9]{4}$", "sample_valid": "2000", "sample_invalid": "12345"},
{"country_code": "NG", "country_name": "Nigeria", "postal_code_regex": "^[0-9]{6}$", "sample_valid": "100001", "sample_invalid": "ABCDE"},
{"country_code": "AR", "country_name": "Argentina", "postal_code_regex": "^[A-Z]\\d{4}[A-Z]{3}$", "sample_valid": "C1000ABC", "sample_invalid": "12345"},
{"country_code": "KR", "country_name": "South Korea", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "04524", "sample_invalid": "ABCDE"},
{"country_code": "SE", "country_name": "Sweden", "postal_code_regex": "^[0-9]{3} [0-9]{2}$", "sample_valid": "114 31", "sample_invalid": "12345"},
{"country_code": "CH", "country_name": "Switzerland", "postal_code_regex": "^[1-9][0-9]{3}$", "sample_valid": "8001", "sample_invalid": "ABCDE"},
{"country_code": "NL", "country_name": "Netherlands", "postal_code_regex": "^[1-9][0-9]{3} ?[A-Z]{2}$", "sample_valid": "1234 AB", "sample_invalid": "12345"},
{"country_code": "BE", "country_name": "Belgium", "postal_code_regex": "^[1-9][0-9]{3}$", "sample_valid": "1000", "sample_invalid": "ABCDE"},
{"country_code": "PL", "country_name": "Poland", "postal_code_regex": "^[0-9]{2}-[0-9]{3}$", "sample_valid": "00-001", "sample_invalid": "12345"},
{"country_code": "SG", "country_name": "Singapore", "postal_code_regex": "^[0-9]{6}$", "sample_valid": "048616", "sample_invalid": "ABCDE"},
{"country_code": "NZ", "country_name": "New Zealand", "postal_code_regex": "^[0-9]{4}$", "sample_valid": "6011", "sample_invalid": "12345"},
{"country_code": "AE", "country_name": "United Arab Emirates", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "00001", "sample_invalid": "ABCDE"},
{"country_code": "TR", "country_name": "Turkey", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "34000", "sample_invalid": "ABCDE"},
{"country_code": "FI", "country_name": "Finland", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "00100", "sample_invalid": "ABCDE"},
{"country_code": "DK", "country_name": "Denmark", "postal_code_regex": "^[0-9]{4}$", "sample_valid": "2100", "sample_invalid": "ABCDE"},
{"country_code": "NO", "country_name": "Norway", "postal_code_regex": "^[0-9]{4}$", "sample_valid": "0150", "sample_invalid": "ABCDE"},
{"country_code": "IE", "country_name": "Ireland", "postal_code_regex": "^[A-Za-z]\\d{2} ?[A-Za-z0-9]{4}$", "sample_valid": "D02 X285", "sample_invalid": "12345"},
{"country_code": "PT", "country_name": "Portugal", "postal_code_regex": "^[0-9]{4}-[0-9]{3}$", "sample_valid": "1000-001", "sample_invalid": "ABCDE"},
{"country_code": "HU", "country_name": "Hungary", "postal_code_regex": "^[0-9]{4}$", "sample_valid": "1051", "sample_invalid": "ABCDE"},
{"country_code": "GR", "country_name": "Greece", "postal_code_regex": "^[0-9]{3} ?[0-9]{2}$", "sample_valid": "151 24", "sample_invalid": "ABCDE"},
{"country_code": "RO", "country_name": "Romania", "postal_code_regex": "^[0-9]{6}$", "sample_valid": "010011", "sample_invalid": "ABCDE"},
{"country_code": "CZ", "country_name": "Czech Republic", "postal_code_regex": "^[0-9]{3} ?[0-9]{2}$", "sample_valid": "110 00", "sample_invalid": "ABCDE"},
{"country_code": "AT", "country_name":"Austria", "postal_code_regex": "^[0-9]{4}$", "sample_valid": "1010", "sample_invalid": "ABCDE"},
{"country_code": "HR", "country_name": "Croatia", "postal_code_regex": "^[1-5][0-9]{4}$", "sample_valid": "10000", "sample_invalid": "ABCDE"},
{"country_code": "EG", "country_name": "Egypt", "postal_code_regex": "^[1-9][0-9]{4}$", "sample_valid": "11511", "sample_invalid": "ABCDE"},
{"country_code": "TH", "country_name": "Thailand", "postal_code_regex": "^[1-9][0-9]{4}$", "sample_valid": "10110", "sample_invalid": "ABCDE"},
{"country_code": "MA", "country_name": "Morocco","postal_code_regex": "^[1-9][0-9]{4}$","sample_valid": "10000", "sample_invalid": "ABCDE"},
{"country_code": "PH", "country_name": "Philippines", "postal_code_regex": "^[0-9]{4}$", "sample_valid": "1000", "sample_invalid": "ABCDE"},
{"country_code": "CL", "country_name": "Chile", "postal_code_regex": "^\\d{7}$", "sample_valid": "8320000", "sample_invalid": "12345"},
{"country_code": "IL", "country_name": "Israel", "postal_code_regex": "^\\d{7}$", "sample_valid": "9614303", "sample_invalid": "ABCDE"},
{"country_code": "MY", "country_name": "Malaysia", "postal_code_regex": "^\\d{5}$", "sample_valid": "50450", "sample_invalid": "ABCDE"},
{"country_code": "VN", "country_name": "Vietnam", "postal_code_regex": "^\\d{6}$", "sample_valid": "700000", "sample_invalid": "ABCDE"},
{"country_code": "UY", "country_name": "Uruguay", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "11600", "sample_invalid": "ABCDE"},
{"country_code": "CO", "country_name": "Colombia", "postal_code_regex": "^[0-9]{6}$", "sample_valid": "110011", "sample_invalid": "12345"},
{"country_code": "PE", "country_name": "Peru", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "15001", "sample_invalid": "ABCDE"},
{"country_code": "EC", "country_name": "Ecuador", "postal_code_regex": "^[0-9]{6}$", "sample_valid": "170135", "sample_invalid": "12345"},
{"country_code": "CR", "country_name": "Costa Rica", "postal_code_regex": "^[0-9]{5}$", "sample_valid": "10101", "sample_invalid": "ABCDE"}
{
"country_code": "IN",
"country_name": "India",
"postal_code_regex": "^[1-9][0-9]{5}$",
"sample_valid": "110001",
"sample_invalid": "000000",
"local_name": "भारत",
"description": "Indian PIN codes are six digits; the first digit represents the postal zone."
},
{
"country_code": "US",
"country_name": "United States",
"postal_code_regex": "^[0-9]{5}(?:-[0-9]{4})?$",
"sample_valid": "12345-6789",
"sample_invalid": "ABCDE",
"local_name": "United States",
"description": "US ZIP codes are five digits, with an optional four-digit extension after a dash."
},
{
"country_code": "DE",
"country_name": "Germany",
"postal_code_regex": "^[0-9]{5}$",
"sample_valid": "10115",
"sample_invalid": "ABCDE",
"local_name": "Deutschland",
"description": "German postal codes (PLZ) are five digits; the first two digits denote the region."
},
{
"country_code": "JP",
"country_name": "Japan",
"postal_code_regex": "^\\d{3}-\\d{4}$",
"sample_valid": "100-0001",
"sample_invalid": "1234567",
"local_name": "日本",
"description": "Japanese postal codes are seven digits written as three digits, a hyphen, then four digits."
},
{
"country_code": "FR",
"country_name": "France",
"postal_code_regex": "^[0-9]{5}$",
"sample_valid": "75001",
"sample_invalid": "1234",
"local_name": "France",
"description": "French postal codes are five digits; the first two digits represent the département."
},
{
"country_code": "BR",
"country_name": "Brazil",
"postal_code_regex": "^\\d{5}-\\d{3}$",
"sample_valid": "01001-000",
"sample_invalid": "12345",
"local_name": "Brasil",
"description": "Brazilian CEP codes are eight digits written as five digits, a hyphen, then three digits."
},
{
"country_code": "GB",
"country_name": "United Kingdom",
"postal_code_regex": "^(GIR 0AA|[A-Z]{1,2}\\d[A-Z\\d]? \\d[ABD-HJLNP-UW-Z]{2})$",
"sample_valid": "SW1A 1AA",
"sample_invalid": "12345",
"local_name": "United Kingdom",
"description": "UK postcodes vary in length; they include letters and digits and typically end with two letters."
},
{
"country_code": "CA",
"country_name": "Canada",
"postal_code_regex": "^[A-Za-z]\\d[A-Za-z][ -]?\\d[A-Za-z]\\d$",
"sample_valid": "K1A 0B1",
"sample_invalid": "12345",
"local_name": "Canada",
"description": "Canadian postal codes alternate letters and digits in a six-character format."
},
{
"country_code": "CN",
"country_name": "China",
"postal_code_regex": "^[0-9]{6}$",
"sample_valid": "100000",
"sample_invalid": "12345",
"local_name": "中国",
"description": "Chinese postal codes are six digits; the first two digits indicate the province."
},
{
"country_code": "AU",
"country_name": "Australia",
"postal_code_regex": "^[0-9]{4}$",
"sample_valid": "2000",
"sample_invalid": "12345",
"local_name": "Australia",
"description": "Australian postcodes are four digits; the first digit often represents the state or territory."
}
]

8 changes: 8 additions & 0 deletions src/postal_regex/data/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
"sample_invalid": {
"type": "string",
"description": "An invalid postal code sample for this country"
},
"local_name": {
"type": "string",
"description": "The name of the country in its local language"
},
"description": {
"type": "string",
"description": "A short description of the country's postal code format"
}
},
"additionalProperties": false
Expand Down