Modify

Opened 4 years ago

Last modified 7 months ago

#15250 new enhancement

validating phone numbers

Reported by: A_Pirard Owned by: team
Priority: normal Milestone:
Component: Core validator Version: latest
Keywords: phone 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 (15)

comment:1 Changed 4 years ago by Polarbear-j

comment:2 Changed 4 years ago by Polarbear-j

Component: CoreCore validator

comment:3 Changed 4 years ago by dieterdreist

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:4 Changed 4 years ago by Don-vip

That would be something to implement in Commons Validator.

comment:5 Changed 4 years ago by Don-vip

Keywords: phone added

comment:6 Changed 3 years ago by Don-vip

We could also use Android's libphonenumber.

comment:7 Changed 3 years ago by Ubipo

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 Changed 3 years ago by Ubipo

I was mistaken the scope of libphonenumber, it can indeed format national area codes and subscriber numbers.

comment:9 Changed 21 months ago by Don-vip

Ticket #17923 has been marked as a duplicate of this ticket.

comment:10 Changed 21 months ago by skyper

from #17923 skyper:

I need some support for correct format of phone numbers, e.g. phone=* and contact: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 Changed 17 months ago by gaben

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 Changed 17 months ago by anonymous

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 Changed 7 months ago by gaben

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 Changed 7 months ago by dieterdreist

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 Changed 7 months ago by gaben

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set.
to The owner will be changed from team to the specified user.
The owner will change to A_Pirard
as duplicate The resolution will be set to duplicate.The specified ticket will be cross-referenced with this ticket
The owner will be changed from team to anonymous.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.