Opened 7 years ago
Closed 21 months ago
#15250 closed enhancement (fixed)
validating phone numbers
Reported by: | A_Pirard | Owned by: | gaben |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Plugin | Version: | latest |
Keywords: | phone number validator libphonenumber | Cc: |
Description
In a thread of tagging@… marc marc mentioned that many French phone numbers have a bad format. Confirmed for Australia, ...
In message 2017-09-06 06:56 Re: [Tagging] phone validity - phone "preset", I replied that
$ read -p 'Phone number: ' number; $number =~ ^[+][0-9\ \-]*$ && echo GOOD
Phone number: 866 356 8207
Phone number: +1 866-356-8207
GOOD
does a good basic validation.
Wouldn't it be nice to add it to JOSM?
TIA
Attachments (0)
Change History (19)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Component: | Core → Core validator |
---|
comment:3 by , 7 years ago
According to this tree list in wikipedia, there are no country codes starting with a 0, so the above regex could be changed to [+][1-9]...
comment:5 by , 7 years ago
Keywords: | phone added |
---|
comment:7 by , 7 years ago
Using libphonenumber is definitely an excellent idea, although that would only account for the international prefix.
National area code and subscriber number formatting validation would have to be done on a country-by-country basis.
Just throwing this in here: I made a little tool to do just that (national number validation) for Belgium:
https://wiki.openstreetmap.org/wiki/BpfOsmTool
comment:8 by , 7 years ago
I was mistaken the scope of libphonenumber, it can indeed format national area codes and subscriber numbers.
comment:10 by , 6 years ago
from #17923 skyper:
I need some support for correct format of phone numbers, e.g.
phone=*
andcontact:phone=
. See wiki page.
- a validator check for correct format: `phone=+<country code> <area code> <local number>
- an automatically fix for adding the country code
- a prefill of country code in presets
comment:11 by , 5 years ago
I was thinking about the phone number validation and found this. It would be a nice addition.
If anyone wants to dig deeper, the keyword is ITU-T E.164.
comment:12 by , 5 years ago
I have not read the standards, but want to ask for caution, because there are exceptions (maybe it is in the standards), in Italy the leading zero of the city prefix is NOT removed (have had bad experiences with a webhoster who removed this automatically from the Whois).
comment:13 by , 4 years ago
Good evening everyone, I have some good news for you :) Yesterday I started writing a new JOSM plugin based on the already mentioned libphonenumber library (created by Google, Apache Licensed).
If you want to test the parsing, you can see a demo here (also created by Google).
It's still in the works, but assuredly working. I did it in my free time and planning to release a stable version in a few weeks. Please tell me if you have any feature requests.
comment:14 by , 4 years ago
If you want to test the parsing, you can see a demo
here (also created by Google).
I have tested it and am impressed, it really worked great for the short tests I conducted (correctly identified good and incorrect numbers, told landline from mobile numbers in Italy and Germany
and identified the area, correctly created international number even from italian phone number which keep the leading zero and are not gotten right frequently)
comment:15 by , 4 years ago
Yeah, it works quite well, nearly perfect.
The only issue it can only parse DDI (direct dial-in) numbers in the {number} ext. {extension number}
format. Hashmark and slash not recognized as an extension, so only the number
part will get formatting. I could easily make it work, but the extension part is not standardized anyway, so it's up to the user.
Because it can identify most of the numbers, some advanced checks are also possible.
comment:16 by , 21 months ago
Hey, any new on integrating this or a plugin? I am tired of manually adjusting the phone number format when a machine could easily do it for me...
comment:18 by , 21 months ago
Component: | Core validator → Plugin |
---|---|
Owner: | changed from | to
comment:19 by , 21 months ago
Keywords: | number validator libphonenumber added |
---|---|
Resolution: | → fixed |
Status: | new → closed |
I released the plugins. It consists of two components:
- libphonenumber wrapper plugin, just a repack of the original lib for JOSM
- the actual plugin
To use them, install the phonenumber
from JOSM as usual.
If you find any bugs, please report them here (trac) or on the Github repo.
One important thing to consider is that I could not test in all countries, therefore I'm counting it as a beta software for now.
+1
Here is the link to the start of the thread: https://lists.openstreetmap.org/pipermail/tagging/2017-September/033303.html