@celia i think the only true validation is to text/call it.
but for reliably getting accurate phone numbers globally, the following three items are significant to appear in the UI:
1. the flag emojis
2. +(country code)
3. country name
a hint for the other digits are helpful too
@tychi yeah, I've seen xxx-xxx-xxxx in the US context, but we just go xxxxxxxxxx in India. Idk if there is even an official guide on this internationally, or it's just culture in each country dictating it, even regardless of any official guideline. That would be hard to capture.
I'd love an input that is able to suggest an apt placeholder once a country is selected.
@celia Sorry if it's not what you're looking for or I misunderstood the issue, but have you tried using something like https://gitlab.com/catamphetamine/libphonenumber-js#readme or do you want to implement it from scratch?
@celia Something tells me this is a deep neverending rabbit hole of terror just like timezones and names.
Yours sincerily. The guy with 37 letters in his name, and one of them being a Þ. Also the guy that lives in an area where the clocks were offset by 30 minutes from the capital region not that long ago.
@celia ...with that all said, of these infinite rabbit holes of terrors, the phone number one is probably the shortest one. If that even makes sense.
On a similar note, this whole thread does remind me of this great essay on name validation. https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/
I had to write a validation regex for a major Belgian phone provider once. I can’t find it back, but I had to find and read the official Belgian phone number spec, and it was not an easy task.
Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.