Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Validating Global Phone Numbers 101: A Quick, Easy Tutorial

DZone's Guide to

Validating Global Phone Numbers 101: A Quick, Easy Tutorial

This quick, simple guide will show you how to use Melissa Data's Global Phone Object for simple phone number validation across the world.

· Java Zone
Free Resource

Build vs Buy a Data Quality Solution: Which is Best for You? Gain insights on a hybrid approach. Download white paper now!

With the advent of global communications and business, chances are you are not only capturing addresses of your contacts, but contact phone numbers as well. This is where Melissa's Global Phone Object comes into play.

Global Phone Object validates registered phone numbers in more than 240 countries and territories, as well as enrich your data by appending information such as latitude, longitude, city, predominant language spoken, and more.

Setting up the object is quick and easy, especially if you're a current customer of any other Melissa API.

Here's a quick tutorial.

First, add the Phone Object DLL or .SL file to your project and instantiate an instance of the Global Phone Object:

SET globalPhonePtr as NEW Instance of GlobalPhone


Second, set your license string:

CALL SetLicenseString WITH LicenseString


Next, initialize the data files:

CALL Initialize WITH DataPath RETURNING Result
IF Result <> 0 THEN
     CALL GetInitializeErrorString RETURNING
ErrorString
    PRING "Error: " & ErrorString
ENDIF


Now you're ready to start validating phone numbers! Using the 'Lookup' method, you can now loop through and feed your contact phone numbers through the object. For best results, pass in both the phone number and country associated with it with the Lookup method. If you require all the digits necessary for dialing internationally from your country, you will also need to pass in the Country of Origin (e.g. the country from which the caller is dialing from).

The outputs returned from the Global Phone Object are useful for call-centers or businesses that would benefit from knowing about the general area the contact is located. For instance, the UTC (Universal Time Code) output can help the caller schedule an appropriate time to dial the contact and the language output can provide the caller information on the language most comfortable for the contact.

The appended regional information, such as the latitude, longitude, locality (city), and administrative area (state) can be sued to get a general sense of where the majority of your contacts are located.

If you're capturing international contact information, the Global Phone Object will be a useful tool in determining registered phone numbers, standardizing phone number formats, and understanding more about where the contact is located.

Image title

Click here to test Global Phone for free.

Build vs Buy a Data Quality Solution: Which is Best for You? Maintaining high quality data is essential for operational efficiency, meaningful analytics and good long-term customer relationships. But, when dealing with multiple sources of data, data quality becomes complex, so you need to know when you should build a custom data quality tools effort over canned solutions. Download our whitepaper for more insights into a hybrid approach.

Topics:
java ,validation ,phone number ,tutorial

Published at DZone with permission of Allison Moon, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}