"""Country helpers.""" from abacus_common_data.country import Country from marshmallow import ValidationError from ledger.constants.error import ERROR_UNKNOWN_COUNTRY def validate_country_code(country_code): """Validate a country code parameter.""" try: Country(str(country_code.upper())) except KeyError: raise ValidationError(ERROR_UNKNOWN_COUNTRY.format(code=country_code))