Skip to main content
Pydantic Docs
current

Search documentation

Type to search this documentation.

On this pageOverview

Country

Country definitions that are based on the ISO 3166.

Bases: str

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

Python
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'

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

Type: str

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

Type: str

The country short name.

Type: str

Bases: str

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

Python
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'

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

Type: str

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

Type: str

The country short name.

Type: str

Bases: str

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

Python
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'

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

Type: str

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

Type: str

The country short name.

Type: str

Bases: str

CountryShortName parses country codes in the short name format.

Python
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'

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

Type: str

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

Type: str

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

Type: str

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu