adopted-ember-addons / ember-validators

A collection of EmberJS validators
Other
25 stars 40 forks source link

Non US phone numbers do not validate correctly #47

Open igorT opened 7 years ago

igorT commented 7 years ago

Added a test at https://github.com/offirgolan/ember-validators/pull/46 Maybe for something as complex as phone number, we should delegate to an external/more robust library?

offirgolan commented 7 years ago

@igorT this has been discussed and contemplated a lot about a year ago and we decided that we will not support international phone numbers. There are too many factors to take into consideration so the best solution is to provide a custom regex for the country you are planning to support.

EDIT:

If you know of a clean and minimal solution to this problem, I would not mind exploring it. 😄

urbany commented 7 years ago

This is the best lib I've found but is huge: https://github.com/googlei18n/libphonenumber/

offirgolan commented 7 years ago

@urbany yeah that repo is a bit overkill. I suggest creating your own validator with that API if that is what you need.

MichalBryxi commented 6 years ago

Personally happy to have to provide regex for my own country, not a big deal. But it would be nice to not call the validator type "phone", but "us-phone" or something alike. Went to the source code, visualized the regex, tried to see why it's not matching my phone and finally found this issue. Having the type named "US phone" would give me a hint, that it is not really a bug, but an intentional decision.