Phone Number Validator

Content Type: Module
Categories: Utility

Overview

This module offers various phone number validation options to ensure accurate and reliable contact information. The module enables you to validate phone numbers in real time, ensuring that the data entered is correct and in the correct format. With the ability to validate numbers across multiple countries and carriers, the module ensures that your contact information is up-to-date and accurate. Whether you want to validate numbers for customer support, sales, or marketing purposes, this module has covered you.


The module is a wrapper around the libphonenumber library, maintained by Google. Link to the original repository: https://github.com/google/libphonenumber

Documentation

Description


This module offers various phone number validation options to ensure accurate and reliable contact information. The module enables you to validate phone numbers, ensuring that the data entered is correct and in the correct format.


The module is a wrapper around the libphonenumber library, maintained by Google. Link to the original repository: https://github.com/google/libphonenumber


Typical usage scenario


With the ability to validate numbers across multiple countries and number types, the module ensures that your contact information is up to date and accurate. Whether you want to validate numbers for customer support, sales, or marketing purposes, this module has you covered.


Additionally, the module can be used to format phone numbers in a uniform format. Please see the list below for all available options. The purpose of this module is server-side validation.


Features and limitations


The following library functions are exposed as actions. Please let me know if you would like to see more of them exposed.


  • CanBeInternationallyDialled
  • FormatNumber
  • FormatNumberForMobileDialing
  • GetNumberType
  • IsValidNumber
  • IsValidNumberForRegion


Accepted input:

  • Numbers must be supplied in international format, with a country code and a leading +. The one exception is IsValidNumberForRegion, which takes a country code and therefore also accepts national format.
  • Vanity numbers spelled with letters are supported. +1 800 FLOWERS is read as +1 800-356-9377.
  • Extensions are supported and ignored when validating. ext., ext, extn, x, xt, anexo and # are all recognised.
  • Numbers containing letters that are neither a vanity spelling nor an extension marker raise an error, rather than silently dropping the letters and validating a different number.


Limitations:

  • Because vanity numbers are supported, a typing mistake of three or more letters cannot be distinguished from a deliberate spelling. +31 6 abcd 5678 is accepted and read as +31 6 22235678, since abcd maps to the digits 2223 in the same way FLOWERS maps to 3569377.
  • Validity depends on the numbering-plan data in the bundled library version. Numbers in ranges that have been retired by their country are reported as invalid.


Dependencies


  • Mendix 10.24.21 or above
  • libphonenumber 9.0.34, included as a managed
  • Java dependency


Configuration


No configuration is needed. The actions can be used out of the box.


All parameters are required. If a parameter is empty, the action throws an error. The actions also throw an error when the input cannot be interpreted as a phone number, so configure error handling on the action when passing user-entered text. IsValidNumber returns false only for input that is a well-formed number which is not in use; anything unparseable raises an error instead.

Releases

Version: 2.0.0
Framework Version: 10.24.21
Release Notes:

Added


- Validation gate for letter input. Numbers containing letters that cannot be interpreted are now rejected with a clear error instead of being silently altered. Vanity numbers such as +1 800 FLOWERS and extension markers such as ext., x and anexo remain fully supported.


Changed


- Upgraded libphonenumber from 8.13.5 to 9.0.34

- The library is now a managed Java dependency (vendorlib)

- Corrected the documentation of IsValidNumber and CanBeInternationallyDialled

- Minimum Studio Pro version is now 10.24.21


Breaking


- Letter input now raises an error instead of returning a result. Previously, one or two stray letters were silently deleted and the remaining digits validated, so +31612345678 O returned true for a number the user never entered, and FormatNumber returned the altered number. Such input now raises an error. Microflows that call these actions on user-entered text without error handling will fail where they previously did not.

- Some numbers change validity because of the metadata update. Numbers in ranges that have since been retired, for example Benin's pre-2021 eight-digit numbers, are now correctly reported as invalid. Stored validation results and test fixtures using affected ranges will change.

- Mendix 9 is no longer supported. Use 1.x for apps on Mendix 9.

Version: 1.0.0
Framework Version: 9.6.11
Release Notes: Initial release. Offering the following actions: - CanBeInternationallyDialled - FormatNumber - FormatNumberForMobileDialing - GetNumberType - IsValidNumber - IsValidNumberForRegion