Utility.Numbers (Portico/Z v0.1.0)

Link to this section Summary

Functions

Quick + dirty phone number conversion to e.164

Link to this section Functions

Link to this function

phone_to_e164(phone)

Quick + dirty phone number conversion to e.164

Assumes mostly domestic numbers, and that international numbers are formatted mostly correctly. It'll probably get us 99% of the way there, which is better than importing a giant dependency just for this one thing...

Examples

iex> Utility.Numbers.phone_to_e164("(617) 123-4567")
"+16171234567"

iex> Utility.Numbers.phone_to_e164("+1 (617) 123-4567")
"+16171234567"

iex> Utility.Numbers.phone_to_e164("617.123.4567")
"+16171234567"

iex> Utility.Numbers.phone_to_e164("19042368295")
"+19042368295"

iex> Utility.Numbers.phone_to_e164(nil)
nil