Wednesday 31 May 2017

Implementation : Phone number validation fails with google-libphonenumber

Numbers starting with 8209****** shows invalid number for the given region 'IN'. Here is the npm runkit demo for the same.

https://runkit.com/592d3e4bb70f37001158b54d/592d3e4bb70f37001158b54e

However, the API call with the latest version of google-libphonenumber, shows the accurate result.

http://libphonenumber.appspot.com/phonenumberparser?number=%2B91+8209895324

My assumption is there is something wrong with the implementation.

Here is the complete implementation as it is from npm runkit of google-libphonenumber from

var phoneUtil = require("google-libphonenumber").PhoneNumberUtil.getInstance();
var phoneNumber0 = "+918209000000";
var phoneNumber1 = "+918197800510";
var phoneNumber2 = "+918209895324";
var phone0 = phoneUtil.parse(phoneNumber0); 
var phone1 = phoneUtil.parse(phoneNumber1); 
var phone2 = phoneUtil.parse(phoneNumber2);
console.log(phoneUtil.isValidNumber(phone0)); // failed
console.log(phoneUtil.isValidNumber(phone1)); // success 
console.log(phoneUtil.isValidNumber(phone2)); // failed



via Sushim Mukul Dutta

No comments:

Post a Comment