Skip to main content

A lightweight Python module that validates Australian phone numbers.

Project description

AUSnumtools

About

AUSnumtools is a lightweight Python module that validates Australian phone numbers.

How it works

The Australian Communications and Media Authority (ACMA) outlines the telephone numbering plan for Australia. Specifically, it details the format of a phone number, such as which groups of digits represent an area code or a mobile carrier. This module uses a RegEx pattern of valid Australian phone number ranges and returns a Boolean true or false value.

  • is_au_landline("0212345678") can be used to validate an Australian landline number
  • is_au_mobile("0412345678") can be used to validate an Australian mobile number
  • is_au_smartnum("1800123456") can be used to validate an Australian smart number
  • is_au_number("0812345678") can be used to validate any Australian phone number

It can also consider fictional numbers designated by the ACMA to be invalid as of the v1.1.0 release of this module by setting the blockFiction parameter to True. By default, fictional numbers will not be invalidated.

However, please note that there are limitations to this type of validation:

  • It cannot validate if the geographical code of a landline number does exist (These types of validation may be supported in a future release)
  • It cannot validate if the mobile number is in a range associated with a specific mobile carrier (These types of validation may be supported in a future release)
  • It cannot validate if the mobile number is connected to a specific mobile carrier (Mobile number porting makes this difficult to determine with certainty)
  • It cannot validate if the phone number is allocated to a or belongs to the subscriber (Only the phone carrier can determine this with certainty, however a callback or SMS verification is typically enough for most cases)

Example

If 0412 345 678 is checked as an Australian mobile number:

print(ausnumtools.is_au_mobile("0412345678"))

The output would be True, as Australian mobile numbers begin with 04 followed by eight digits.

If (09) 1234 56789 is checked as an Australian landline number:

print(ausnumtools.is_au_landline("09123456789"))

The output would be False, as the 09 area code does not exist in Australia and is followed by more than eight digits.

If 1300 655 506 is checked as an Australian smart number:

print(ausnumtools.is_au_smartnum("1300655506"))

The output would be True, as 1300 smart numbers are followed by six digits.

If 0491 570 006 is checked as an Australian landline or mobile number and checked against the ACMA's designated fictional numbers:

print(ausnumtools.is_au_number("0491570006", blockFiction=True))

The output would be False, as this Australian mobile number is designated for fictional use by the ACMA and is therefore not available to subscribers.

Install

AUSnumtools is listed on the Python Package Index and can be download via Python's package manager, pip.

pip install ausnumtools

Then, the module can be imported into the desired Python script.

import ausnumtools

Alternatively, the module can be packaged and installed manually. Please consult Python's documentation for such instructions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ausnumtools-1.2.1.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ausnumtools-1.2.1-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file ausnumtools-1.2.1.tar.gz.

File metadata

  • Download URL: ausnumtools-1.2.1.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for ausnumtools-1.2.1.tar.gz
Algorithm Hash digest
SHA256 5988032aaab09b47ee884bb3de6bbf3917381aa7fc8246843d344f81662d8a69
MD5 3e101e52643c9a51c822a6db72a17675
BLAKE2b-256 0829df9aebc830694640aff6d7858fac78acfab10ffa32461193b15913f2956b

See more details on using hashes here.

File details

Details for the file ausnumtools-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: ausnumtools-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for ausnumtools-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 62a53c223ed49bd17b688d838caf046ba09ce6edd2eb7689e4ac984fecafd697
MD5 ef49b91d684ff4c0f0a905348343301d
BLAKE2b-256 36b3aba3dc307ceaff2a8e67526d6947a6dd7043d426b2dee49e6e1359084345

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page