Closed liuzach closed 2 years ago
Using the new API, I pass the phone number to parsePhoneNumber and call .format('NATIONAL') on the result of that.
Yeah, that's the way. Or .formatNational()
.
That works for valid numbers but for invalid numbers it returns the number unformatted
That's also expected.
Is there a way in the newest version to format these numbers that are possible but not valid?
If it's not doing it by default then there's no way.
Hey there,
I recently upgraded from 1.2.15 to 1.9.52 and I noticed that this broke formatting of possible but invalid numbers (such as +11234567890). Previously I was using parseNumber with the extended: true option and passing that result into formatNumber with the 'National' format and that would format the above example number to (123) 456-7890.
After upgrading to the newest version that legacy API no longer seems to work -- it returns an empty string instead of the formatted number. Using the new API, I pass the phone number to parsePhoneNumber and call .format('NATIONAL') on the result of that. That works for valid numbers but for invalid numbers it returns the number unformatted (1234567890 for the example above).
Is there a way in the newest version to format these numbers that are possible but not valid?