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, needs approval). 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 and tag 1.0.0 is there; its commit a6a8426d891d is from 2020-09-17 21:07 UTC, after the version was published (2019-03-02 19:20 UTC); elm.json differs from package.elm-lang.org's; the exposed modules match docs.json; the zip's SHA-1 is not the published one and nothing else confirms its contents.
We could not verify this copy against what was published, so the Lamdera compiler asks before using it (y/n). Without a terminal, as in CI, it stops with an error unless approved:
lamdera make --auto-approve-package-rerouting approves rerouted versions for that run,LAMDERA_AUTO_APPROVE_PACKAGE_REROUTING=1 does the same for every run in that environment,LAMDERA_CACHE=off skips the Lamdera package server altogether: packages come from package.elm-lang.org and GitHub only, as with elm, and a rerouted version then fails to download.Details · package.elm-lang.org's zip: https://github.com/Skinney/elm-phone-numbers/zipball/1.0.0/
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.12.8
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.