Safe Haskell | None |
---|---|
Language | Haskell98 |
- data PhoneNumber = PhoneNumber {}
- data PhoneNumberRef
- data PhoneNumberType
- data PhoneNumberParseError = PhoneNumberParseError Int
- parsePhoneNumber :: ByteString -> ByteString -> Either PhoneNumberParseError PhoneNumber
- parsePhoneNumberRef :: ByteString -> ByteString -> Either PhoneNumberParseError PhoneNumberRef
- refCountryCode :: PhoneNumberRef -> Maybe Word64
- refNationalNumber :: PhoneNumberRef -> Maybe Word64
- refExtension :: PhoneNumberRef -> Maybe ByteString
- refType :: PhoneNumberRef -> PhoneNumberType
- refIsPossibleNumber :: PhoneNumberRef -> Bool
- refIsValidNumber :: PhoneNumberRef -> Bool
- convertAlphaCharacters :: ByteString -> ByteString
Types
data PhoneNumber Source
A data type representation of a phone number, you can build one of these
with copyPhoneNumberRef
given a PhoneNumberRef
, which is simply a
convenience for a series of calls to accessors.
data PhoneNumberType Source
data PhoneNumberParseError Source
There was a problem parting your phone number. For now, if you want to know what the Int here means, you'll need to look at the ErrorType enum in the underlying library.
Parsing
:: ByteString | The phone number to parse |
-> ByteString | A two letter country code for the default region to be assumed |
-> Either PhoneNumberParseError PhoneNumber |
Try to parse a phone number, building a PhoneNumber
including commonly
accessed information.
This is marginally more expensive than parsing a PhoneNumberRef
with
parsePhoneNumberRef
and extracting just the fields that you need, although
the latter will allow you to retrieve more information such as the type of
number (which requires more underlying library calls).
:: ByteString | The phone number to parse |
-> ByteString | A two letter country code for the default region to be assumed |
-> Either PhoneNumberParseError PhoneNumberRef |
Try to parse a PhoneNumberRef
, see the PhoneNumberRef accessors/utilities
section below for useful things to do with the result.
PhoneNumberRef accessors/utilities
Validation
See the libphonenumber javadocs for the distinction between these.
Utility
convertAlphaCharacters :: ByteString -> ByteString Source
Convert any alpha characters in a phone number to their equivalent keypad numbers.