Skip to content

Instantly share code, notes, and snippets.

@mccraigmccraig
Created September 4, 2019 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mccraigmccraig/038776041d6d49e27bb6a7536bd8baf2 to your computer and use it in GitHub Desktop.
Save mccraigmccraig/038776041d6d49e27bb6a7536bd8baf2 to your computer and use it in GitHub Desktop.
(ns er-model.util.phone-number.impl
(:require
["google-libphonenumber"
:refer [PhoneNumber
PhoneNumberUtil
PhoneNumberFormat]]))
(defn phone-number-instance [] (PhoneNumber.))
(defn phone-number-util-instance [] (.getInstance PhoneNumberUtil))
(def key->country-code-source-map
(let [ccs (.-CountryCodeSource PhoneNumber)]
{:from-number-with-plus-sign
(.-FROM_NUMBER_WITH_PLUS_SIGN ccs)
:from-number-with-idd
(.-FROM_NUMBER_WITH_IDD ccs)
:from-number-without-plus-sign
(.-FROM_NUMBER_WITHOUT_PLUS_SIGN ccs)
:from-default-country
(.-FROM_DEFAULT_COUNTRY ccs)}))
(def key->phone-number-format-map
{:E164 (.-E164 PhoneNumberFormat)
:INTERNATIONAL (.-INTERNATIONAL PhoneNumberFormat)
:NATIONAL (.-NATIONAL PhoneNumberFormat)})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment