Skip to content

Phone Numbers

The pydantic_extra_types.phone_numbers module provides the PhoneNumber data type.

This class depends on the [phonenumbers] package, which is a Python port of Google's [libphonenumber].

PhoneNumber

Bases: str

A wrapper around phonenumbers package, which is a Python port of Google's libphonenumber.

supported_regions class-attribute instance-attribute

supported_regions = sorted(SUPPORTED_REGIONS)

The supported regions.

supported_formats class-attribute instance-attribute

supported_formats = sorted([f for f in keys() if isupper()])

The supported phone number formats.

default_region_code class-attribute

default_region_code = None

The default region code to use when parsing phone numbers without an international prefix.

phone_format class-attribute instance-attribute

phone_format = 'RFC3966'

The format of the phone number.

min_length class-attribute instance-attribute

min_length = 7

The minimum length of the phone number.

max_length class-attribute instance-attribute

max_length = 64

The maximum length of the phone number.