Validate Country, State, and Zip Codes

The lookup file

The lookup file provides a comprehensive list of valid codes for countries, states, and postal or ZIP codes. It includes two-letter ISO codes for countries, valid state or province codes for each country, and valid postal or ZIP codes for each region or locality.

Country and state ISO codes are typically represented by two letters (such as "US" for the United States, and "CA" for California), while ZIP codes vary in format depending on the country.

Socure's lookup file is a CSV file that contains the following columns:

Below is the file's snippet:

Validate a code using the lookup file

To validate a country, state, or ZIP code, compare the input code with the data in the file:

Below are example inputs and the expected validation results:

Input Validation Result Reason
CA Valid CA is a valid state code.
US Valid US is a valid country code.
V3B6K9 Valid The input matches the ZIP code format ANA NAN and ZIP code regex ^[A-Za-z]\d[A-Za-z]\s\d[A-Za-z]\d$ for Canadian ZIP codes.
5200B, FR Invalid The input does not match the ZIP code format NNNNN for French ZIP codes.