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.77k stars 217 forks source link

Cannot understand `defaultCountry` parameter in `parsePhoneNumber` #357

Closed cyrilgandon closed 4 years ago

cyrilgandon commented 4 years ago

See this example, with a Marrocean phone number, parsed with a France country code:

parsePhoneNumber("+212635607833", "FR");

It returns a valid phone number:

{
    country: "MA"
    countryCallingCode: "212"
    nationalNumber: "635607833"
    number: "+212635607833"
}

What is the point of the defaultCountry parameter ? I was expected an error, or an invalid phoneNumber.

catamphetamine commented 4 years ago

defaultCountry is for parsing non-international phone numbers