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.0.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.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ausnumtools-1.2.0.tar.gz
Algorithm Hash digest
SHA256 ca5e03fea4fa1a482aa2fea53840dacd521ae57c111ca02aa605681ac8a0c111
MD5 ea5441ee8ab9290444e73a76049e34ba
BLAKE2b-256 60c2c73a05e0c762c99d642ad64503a54b652d6676c3703b42c6e6303b7c8636

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ausnumtools-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 715b2f4d09f8aa187216671b501ce408b3b0e0d021bb308eb2fc6a2dc369173b
MD5 93d59088b4bd962e55422bb8996bf80b
BLAKE2b-256 b8a03ff0c0b514d67c65c48dddf01bbac41ac0a0dcb8c836787cefb430d21eb8

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