AfterShip / phone

With a given country and phone number, validate and reformat the mobile phone number to the E.164 standard. The purpose of this is to allow us to send SMS to mobile phones only.
https://www.aftership.com
MIT License
846 stars 268 forks source link

Puerto Rico area codes not valid for US #297

Closed lsacco-nutreense closed 2 years ago

lsacco-nutreense commented 2 years ago

Great library btw, but we've noticed that 787/939 are coming back as invalid phones when either specifying US as the country or no country (US/CA). These are valid area codes. It is a protectorate/territory of the US and uses the +1 country code. Can this be added so it will validate properly? Thanks!

Bossa573 commented 2 years ago

Please provide related docs / websites / proof showing that 787 and 939 are the valid US mobile phone number prefix, thank you

lsacco-nutreense commented 2 years ago

Well, I suppose we can use deductive reasoning. Puerto Rico is a territory of the United State and not its own country and therefore has a country code of +1 when dialing to PR. You can refer to this from the us.gov website. I hope that helps.

Bossa573 commented 2 years ago

it didn't show it was a valid mobile phone number prefix

please check this section: https://github.com/AfterShip/phone#skipping-phone-number-initial-digit-checking

lsacco-nutreense commented 2 years ago

Why do you emphasize mobile? These are the general area codes for PR; it has nothing to do with mobile per se. In my case, these are landlines. My feeling is that the lib should treat area codes in US or any of its territories as US.

Bossa573 commented 2 years ago

I cannot tell if 787 and 939 phone number prefix also apply to a valid US mobile phone number (I'm not an American btw 🙂) as for many countries, it does matter, mobile phone number and landline does not share same set of phone number prefix

lsacco-nutreense commented 2 years ago

Oh, LOL. Sorry I didn't know that. Yeah, in the US, mobile and landlines share the same area code. It's one of the reasons why they kept expanding area codes because they ran out of numbers from more mobile users. 😄

You can see here that they are allocated to PR: https://www.allareacodes.com/787 https://www.allareacodes.com/939. Not sure if that's a definitive source, but for what it's worth.

Bossa573 commented 2 years ago

oh cool, also checked allareacodes.com URLs, if US mobile and landlines share the same area code, I'll add both 787 and 939 as well, and would be included in the next release, thank you

Bossa573 commented 2 years ago

https://github.com/AfterShip/phone/releases/tag/3.1.19 https://www.npmjs.com/package/phone/v/3.1.19

lsacco-nutreense commented 2 years ago

Thank you sir. I'll keep an eye out and upgrade. Have a good day!

Bossa573 commented 2 years ago

As the new version is published, I'll close this ticket, feel free to reopen the ticket if needed, thank you