ember-validators icon indicating copy to clipboard operation
ember-validators copied to clipboard

Non US phone numbers do not validate correctly

Open igorT opened this issue 8 years ago • 4 comments

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?

igorT avatar Mar 28 '17 22:03 igorT

@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. 😄

offirgolan avatar Mar 29 '17 18:03 offirgolan

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

urbany avatar May 05 '17 10:05 urbany

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

offirgolan avatar May 12 '17 01:05 offirgolan

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.

MichalBryxi avatar Sep 27 '18 11:09 MichalBryxi