Popularity
7.9
Growing
Activity
4.9
Declining
164
22
36

Monthly Downloads: 987,204
Programming language: Elixir
License: MIT License
Tags: Miscellaneous    
Latest version: v0.2.1

ex_phone_number alternatives and similar packages

Based on the "Miscellaneous" category.
Alternatively, view ex_phone_number alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of ex_phone_number or a related project?

Add another 'Miscellaneous' Package

README

ExPhoneNumber

Build Status Hex Version

It's a library for parsing, formatting, and validating international phone numbers. Based on Google's libphonenumber (current metadata version: 8.10.2).

Installation

  1. Add :ex_phone_number to your list of dependencies in mix.exs: elixir def deps do [{:ex_phone_number, "~> 0.2"}] end

Usage

iex> {:ok, phone_number} = ExPhoneNumber.parse("044 668 18 00", "CH")
{:ok,
 %ExPhoneNumber.Model.PhoneNumber{
   country_code: 41,
   country_code_source: nil,
   extension: nil,
   italian_leading_zero: nil,
   national_number: 446681800,
   number_of_leading_zeros: nil,
   preferred_domestic_carrier_code: nil,
   raw_input: nil
}}

iex> ExPhoneNumber.is_possible_number?(phone_number)
true

iex> ExPhoneNumber.is_valid_number?(phone_number)
true

iex> ExPhoneNumber.get_number_type(phone_number)
:fixed_line

iex> ExPhoneNumber.format(phone_number, :national)
"044 668 18 00"

iex> ExPhoneNumber.format(phone_number, :international)
"+41 44 668 18 00"

iex> ExPhoneNumber.format(phone_number, :e164)
"+41446681800"

iex> ExPhoneNumber.format(phone_number, :rfc3966)
"tel:+41-44-668-18-00"

E164 formatted numbers

In e164 formatted numbers the country code can be detected. So you can pass them in to parse/2 with "" or nil as the second argument.

iex(2)> ExPhoneNumber.parse("+977123456789", "")
{:ok,
 %ExPhoneNumber.Model.PhoneNumber{
   country_code: 977,
   country_code_source: nil,
   extension: nil,
   italian_leading_zero: nil,
   national_number: 123456789,
   number_of_leading_zeros: nil,
   preferred_domestic_carrier_code: nil,
   raw_input: nil
 }}

Copyright and License

Copyright (c) 2016-2020 NLCollect B.V.

The source code is licensed under [The MIT License (MIT)](LICENSE.md)


*Note that all licence references and agreements mentioned in the ex_phone_number README section above are relevant to that project's source code only.