$validator = Validation::createValidator();
// Create a list of countries for which Google has definitions.
$foundCountries = ['ZZ'];
$countryRepository = new CountryRepository();
$countries = $countryRepository->getList();
$serviceUrl = 'http://i18napis.appspot.com/address';
$index = file_get_contents($serviceUrl);
foreach ($countries as $countryCode => $countryName) {
    $link = "<a href='/address/data/{$countryCode}'>";
    // This is still faster than running a file_exists() for each country code.
    if (strpos($index, $link) !== FALSE) {
        $foundCountries[] = $countryCode;
    }
}
foreach ($foundCountries as $countryCode) {
    $addressFormat = $addressFormatRepository->get($countryCode);
    if (!in_array(AddressField::POSTAL_CODE, $addressFormat->getUsedFields())) {
        continue;
    }
    $definition = file_get_contents('raw/' . $countryCode . '.json');
    $definition = json_decode($definition, TRUE);
    // If country definition has zip examples, check if they pass validation.
    if (isset($definition['zipex'])) {
        $zipExamples = explode(',', $definition['zipex']);
        $address = $address->withCountryCode($countryCode);
        foreach ($zipExamples as $zipExample) {
            if (strpos($zipExample, ':') !== FALSE) {
                // Ignore ranges for now, the non-range examples are enough.
                continue;
            }
            $address = $address->withPostalCode($zipExample);