Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"Phone numbers are numbers" - I've come this multiple times integrating phone numbers into a product.

Currently I just store phone numbers in E.164 format as a string with max length of 25 just to be safe and index them. This really takes up no additional space and can easily handle extensions.

I can't tell you how many times I've run into people storing phone numbers without normalization eg: "(555) 444 - 3333" etc., not understanding that's hard to compare against, where E.164 = "+15554443333" is much more consistent and also works with services like twilio etc.



I assume why they store them as entered is because it's hard to convert them between formats. In North America you format the number that way, but other countries do it differently. Maybe the phone number is a local number (without area code) or maybe it has an extension?

If you are just storing the phone number to display to a user at a later time, it is a lot simpler just to save it as text field with no validation.


>Currently I just store phone numbers in E.164 format as a string

As someone who created many texting apps (HeyWire, Salesforce's LiveMessage Product) this is how all numbers are treated internally...except short codes, which aren't phone numbers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: