On my website, people can register with their telephone number. Only one account per phone number is allowed. The problem is: a phone number can be written in several ways.
I'm from Belgium. Our (mobile) phone numbers are like this: 04xx xx xx xx (for example 04 99 12 34 56). Belgium's country code is 0032, so 0032499 12 34 56 is also a valid phone number, just like +32499 12 34 56 is.
So no I have three phone numbers which are exactly the same, but are written different and the system does not recognize them as the same.
Possible solution (will not work)
Every Belgian phone number has the same ending:
00324xxxxxxxx
+324xxxxxxxx
04xxxxxxxx
I could check the last 9 digits (starting with 4), but the problem is: not only people from Belgium can register, also other countries can register. A US mobile phone number does not end with 4xxxxxxxx, so I could not do this check on these numbers.
Possible solution
Adding a dropdown with all the country codes, and normalizing every phone number before it is submitted.
For Belgian phone numbers: +32 (dropdown) 0499 12 34 56 (input) would become +32 (dropdown) 499 12 34 56 (strip the 0).
Possible solution 2
I could use an API like this one (https://www.searchbug.com/api/identify-phone-number.aspx) but it's not free. Is there a free solution I can host myself?