catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.79k stars 216 forks source link

Validate true if using 00 instead of + #207

Closed jhalborg closed 6 years ago

jhalborg commented 6 years ago

It seems a lot of my users write their country prefix with 00 instead of + notation. I've now rebuilt the UI so they input country code in one box and the number in the other and validate the result myself so there's no UX confusion, but I think it'd be natural if

+45 12345678 and 0045 12345678 both validated true as DK phone numbers

catamphetamine commented 6 years ago

Why are your users inputting their phone number with 00 prefix?

catamphetamine commented 6 years ago

Released 1.2.0 which supports parsing IDD prefixes.

const number = parseNumber('011 61 2 3456 7890', { fromCountry: 'US' })
// Returns `{ country: 'AU', phone: '234567890' }`
isValidNumber(number)
jhalborg commented 6 years ago

Why are your users inputting their phone number with 00 prefix?

Because, users! ;) I guess some just have that preference, what can I say :)

But that sounds great, I'll check it out

catamphetamine commented 6 years ago

FYI: I removed fromCountry parameter from parseNumber(). It now uses "default country" instead.

Chicooz commented 6 years ago

@catamphetamine users outside of the states and some European countries doesn't even know what the +is and they always use 00, and really it should be recognizes the same as +

catamphetamine commented 6 years ago

@Chicooz As I aready wrote, 00 numbers are IDD and IDD are numbers dialed from country A to country B. The input component only has country B.