Closed ORESoftware closed 9 years ago
Phone number validation is tough (see how big this repo is: https://github.com/googlei18n/libphonenumber), but mobile phones tend to be easier to validate and so it's here in the library ;)
You can see the patterns in use here: https://github.com/chriso/validator.js/blob/b20a8db53b112eea86dfed9b9d6efabb4cde63de/validator.js#L82-L93
Do give you an example, all mobile phone numbers in Australia start with 04 and can be validated with /^04\d{8}$/
locally, or /^+?614\d{8}$/
for international versions of the same numbers. Landlines start with 02, 03, 05 and 07 (and probably others) depending on the state and have additional rules in place for each region. I'm not familiar with the rules of other countries and so have relied on pull requests to add locales.
I didn't see any clarification as to if the mobile phone number validator checks to see if a phone number is a mobile phone number and not a landline or if it just eliminates 800 numbers, etc.
I did check and it doesn't accept (800)555-0101 numbers, but does it accept any other landline numbers?
How does it differentiate? It can't possibly differentiate between landline numbers and mobile numbers without using a database, right?
Explanation desired, thanks!