{"id":9787,"library":"google-i18n-address","title":"Address Validation for International Addresses","description":"google-i18n-address provides address validation helpers leveraging Google's international address database. It helps in validating, normalizing, and latinizing addresses for various countries. The library is currently at version 3.1.1 and receives updates typically for database rule changes or minor packaging improvements.","status":"active","version":"3.1.1","language":"en","source_language":"en","source_url":"https://github.com/mirumee/google-i18n-address","tags":["i18n","address","validation","localization","geospatial"],"install":[{"cmd":"pip install google-i18n-address","lang":"bash","label":"Install stable release"}],"dependencies":[],"imports":[{"note":"The PyPI package `google-i18n-address` is imported as `i18naddress`.","wrong":"from google_i18n_address import Address","symbol":"Address","correct":"from i18naddress import Address"},{"note":"The PyPI package `google-i18n-address` is imported as `i18naddress`.","wrong":"from google_i18n_address import AddressValidator","symbol":"AddressValidator","correct":"from i18naddress import AddressValidator"},{"note":"The PyPI package `google-i18n-address` is imported as `i18naddress`.","wrong":"from google_i18n_address import get_validation_rules","symbol":"get_validation_rules","correct":"from i18naddress import get_validation_rules"},{"note":"Exception name changed in v3.0.0. The package name is `i18naddress`.","wrong":"from i18naddress.errors import InvalidAddress","symbol":"InvalidAddressError","correct":"from i18naddress.errors import InvalidAddressError"}],"quickstart":{"code":"from i18naddress import Address, AddressValidator, get_validation_rules\n\naddress_data = {\n    'country_code': 'US',\n    'street_address': '1600 Amphitheatre Pkwy',\n    'city': 'Mountain View',\n    'postal_code': '94043',\n    'country_area': 'CA'\n}\n\n# Create an Address object\naddress = Address(**address_data)\n\n# Get validation rules for the address's country\nrules = get_validation_rules(address_data)\n\n# Validate the address\nerrors = AddressValidator().validate(address, rules)\n\nif errors:\n    print(f\"Validation errors: {errors}\")\nelse:\n    print(\"Address is valid.\")\n\n# Example of getting normalized address\nnormalized_address = address.normalize()\nprint(f\"Normalized address: {normalized_address.as_dict()}\")","lang":"python","description":"This quickstart demonstrates how to validate an international address using Address, AddressValidator, and get_validation_rules. It also shows how to normalize an address object."},"warnings":[{"fix":"Update your exception handling from `except InvalidAddress:` to `except InvalidAddressError:` and ensure you import `InvalidAddressError` from `i18naddress.errors`.","message":"The exception class `InvalidAddress` was renamed to `InvalidAddressError` for PEP8 compliance.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"If your code expects `postal_code_examples` to be a string, update it to handle a list, e.g., `rules.postal_code_examples[0]` for the first example or iterate over the list.","message":"The `ValidationRules.postal_code_examples` attribute changed its type from a string to a list of strings.","severity":"breaking","affected_versions":">=2.2.0"},{"fix":"Always use `import i18naddress` or `from i18naddress import ...` in your code, not `google_i18n_address`.","message":"The Python package name is `google-i18n-address` on PyPI, but its top-level import is `i18naddress`.","severity":"gotcha","affected_versions":"*"},{"fix":"Review any custom validation logic that relies on empty non-required fields being flagged as invalid when a choice list is present. Adjust expectations or add explicit checks if needed.","message":"Validation logic for non-required fields changed. Empty fields that are not explicitly required will no longer be marked as invalid, even if a list of choices for that field exists.","severity":"gotcha","affected_versions":">=2.3.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Change `InvalidAddress` to `InvalidAddressError` and ensure it's imported correctly: `from i18naddress.errors import InvalidAddressError`.","cause":"Your code is using the old exception name `InvalidAddress` with version 3.0.0 or newer of the library.","error":"NameError: name 'InvalidAddress' is not defined"},{"fix":"Modify your code to treat `postal_code_examples` as a list. For example, access `rules.postal_code_examples[0]` for the first example or iterate over the list.","cause":"Your code expects `ValidationRules.postal_code_examples` to be a string, but it is now a list of strings in versions 2.2.0 and later.","error":"AttributeError: 'list' object has no attribute 'startswith'"},{"fix":"Replace all instances of `import google_i18n_address` or `from google_i18n_address import ...` with `import i18naddress` or `from i18naddress import ...`.","cause":"You are attempting to import the library using `google_i18n_address`, but the correct import path is `i18naddress`.","error":"ModuleNotFoundError: No module named 'google_i18n_address'"}]}