I am using the libphonenumber library for node.js
In the google demo for this library, if I enter an invalid phone number, the intl format is not populated. But when I try to parse an invalid number via node.js library, it creates the intl string representation irrespective of whether the number is valid or not.
I need to make sure that only valid numbers are converted and invalids to return null.
As an example, consider this:
var phoneProto = phoneUtil.parse("12213", "IN");
phoneProto.intl = phoneUtil.format(phoneProto, 1);
sails.log.debug(phoneProto.intl);
Output
+91 12213
How can I make sure only valid ones are returned ?