Open igorT opened 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. 😄
This is the best lib I've found but is huge: https://github.com/googlei18n/libphonenumber/
@urbany yeah that repo is a bit overkill. I suggest creating your own validator with that API if that is what you need.
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.
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?