Skip to content

Country

Country definitions that are based on the ISO 3166.

CountryAlpha2

Bases: str

CountryAlpha2 parses country codes in the ISO 3166-1 alpha-2 format.

from pydantic import BaseModel

from pydantic_extra_types.country import CountryAlpha2

class Product(BaseModel):
    made_in: CountryAlpha2

product = Product(made_in='ES')
print(product)
#> made_in='ES'

alpha3 property

alpha3: str

The country code in the ISO 3166-1 alpha-3 format.

numeric_code property

numeric_code: str

The country code in the ISO 3166-1 numeric format.

short_name property

short_name: str

The country short name.

official_name property

official_name: str

The country official name.

CountryAlpha3

Bases: str

CountryAlpha3 parses country codes in the ISO 3166-1 alpha-3 format.

from pydantic import BaseModel

from pydantic_extra_types.country import CountryAlpha3

class Product(BaseModel):
    made_in: CountryAlpha3

product = Product(made_in="USA")
print(product)
#> made_in='USA'

alpha2 property

alpha2: str

The country code in the ISO 3166-1 alpha-2 format.

numeric_code property

numeric_code: str

The country code in the ISO 3166-1 numeric format.

short_name property

short_name: str

The country short name.

official_name property

official_name: str

The country official name.

CountryNumericCode

Bases: str

CountryNumericCode parses country codes in the ISO 3166-1 numeric format.

from pydantic import BaseModel

from pydantic_extra_types.country import CountryNumericCode

class Product(BaseModel):
    made_in: CountryNumericCode

product = Product(made_in="840")
print(product)
#> made_in='840'

alpha2 property

alpha2: str

The country code in the ISO 3166-1 alpha-2 format.

alpha3 property

alpha3: str

The country code in the ISO 3166-1 alpha-3 format.

short_name property

short_name: str

The country short name.

official_name property

official_name: str

The country official name.

CountryShortName

Bases: str

CountryShortName parses country codes in the short name format.

from pydantic import BaseModel

from pydantic_extra_types.country import CountryShortName

class Product(BaseModel):
    made_in: CountryShortName

product = Product(made_in="United States")
print(product)
#> made_in='United States'

alpha2 property

alpha2: str

The country code in the ISO 3166-1 alpha-2 format.

alpha3 property

alpha3: str

The country code in the ISO 3166-1 alpha-3 format.

numeric_code property

numeric_code: str

The country code in the ISO 3166-1 numeric format.

official_name property

official_name: str

The country official name.

CountryOfficialName

Bases: str

CountryOfficialName parses country codes in the official name format.

from pydantic import BaseModel

from pydantic_extra_types.country import CountryOfficialName

class Product(BaseModel):
    made_in: CountryOfficialName

product = Product(made_in="United States of America")
print(product)
#> made_in='United States of America'

alpha2 property

alpha2: str

The country code in the ISO 3166-1 alpha-2 format.

alpha3 property

alpha3: str

The country code in the ISO 3166-1 alpha-3 format.

numeric_code property

numeric_code: str

The country code in the ISO 3166-1 numeric format.

short_name property

short_name: str

The country short name.