# Phone Numbers

This package uses metadata from Google's [libphonenumber](https://github.com/googlei18n/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.7.

## How to use

The first thing you need, is a `ValidationConfig`. The config consists of three things:

(1) the countries you wish to validate the phone number against.
(2) the country you wish to validate the phone number against if it does not contain an international prefix.
(3) the types of phone numbers you are interested in validating against (fixed line, mobile, emergency...)

If you do not specify a default country (2), then it will try to validate the number against all countries you have provided metadata for.

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.

## Examples

    import PhoneNumber
    import PhoneNumber.Countries exposing (countryNO)

    validNorwegianNumber : String -> Bool
    validNorwegianNumber number =
        PhoneNumber.valid
            { countries = [ countryNO ]
            , defaultCountry = Nothing -- This doesnt really matter when the list of countries == 1
            , types = PhoneNumber.anyType
            }
            number

    validNorwegianCellNumber : String -> Bool
    validNorwegianCellNumber number =
        PhoneNumber.valid
            { countries = [ countryNO ]
            , defaultCountry = Nothing
            , types = [ PhoneNumber.Mobile ]
            }
            number

## Recommeded reading

Definetly check out [falsehoods people believe about phone numbers](https://github.com/googlei18n/libphonenumber/blob/master/FALSEHOODS.md) before using this library.
