Renamed to robinheghan/elm-phone-numbers. It is published under that name, and new versions come out there.
Versions published as Skinney/elm-phone-numbers still install under that name. 32 versions of 32 come from the new location (see their notes).
Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/robinheghan/elm-phone-numbers.
What we checked: The repo moved to github.com/robinheghan/elm-phone-numbers. Rebuilt with git archive from commit c125b596f5f4 of https://github.com/robinheghan/elm-phone-numbers (zip prefix Skinney-elm-phone-numbers-c125b59/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 0a63aff869d9f6f42aa6b83ea6938e04544ee623.
The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.
Details · package.elm-lang.org's zip: https://github.com/Skinney/elm-phone-numbers/zipball/2.0.15/
This package uses metadata from Google's libphonenumber (which again is used in the Android OS) to validate international phone numbers. You can find phone-related metadata for most countries in the PhoneNumber.Countries module.
The metadata is up to date with libphonenumber v8.10.21.
The first thing you need, is a ValidationConfig. The config consists of three things:
(1) the country you wish to validate the phone number against, even if it does not contain an international prefix. (2) any additional countries you wish to validate the number against if it has a international prefix. (3) the types of phone numbers you are interested in validating against (fixed line, mobile, emergency...)
Also note that for reasons of performance and asset size, you should try to keep the list of country metadata and number types as small as possible.
import PhoneNumber
import PhoneNumber.Countries exposing (countryNO)
validNorwegianNumber : String -> Bool
validNorwegianNumber number =
PhoneNumber.valid
{ defaultCountry = countryNO
, otherCountries = []
, types = PhoneNumber.anyType
}
number
validNorwegianCellNumber : String -> Bool
validNorwegianCellNumber number =
PhoneNumber.valid
{ defaultCountry = countryNO
, otherCountries = []
, types = [ PhoneNumber.Mobile ]
}
numberDefinetly check out falsehoods people believe about phone numbers before using this library.