-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.json
1 lines (1 loc) · 5.24 KB
/
params.json
1
{"name":"Globalphone","tagline":"GlobalPhone parses, validates, and formats local and international phone numbers","body":"GlobalPhone parses, validates, and formats local and international phone numbers according to the [E.164 standard](http://en.wikipedia.org/wiki/E.164).\r\n\r\n**Store and display phone numbers in your app.** Accept phone number input in national or international format. Convert phone numbers to international strings (`+13125551212`) for storage and retrieval. Present numbers in national format (`(312) 555-1212`) in your UI.\r\n\r\n**Designed with the future in mind.** GlobalPhone uses format specifications from Google's open-source [libphonenumber](http://code.google.com/p/libphonenumber/) database. No need to upgrade the library when a new phone format is introduced—just generate a new copy of the database and check it into your app.\r\n\r\n## Installation\r\n\r\n1. Add the `GlobalPhone` nuget package to your app. For example, using Package Manager Console:\r\n\r\n PM> Install-Package GlobalPhone\r\n\r\n2. Use `GlobalPhoneDbgen` to convert Google's libphonenumber `PhoneNumberMetaData.xml` file into a JSON database for GlobalPhone. You can either install it using nuget in some project:\r\n\r\n PM> Install-Package GlobalPhoneDbgen\r\n\r\nOr you can add it as a solution level package.\r\n\r\nHowever you have installed it, you can then use the command prompt to execute the exe: \r\n\r\n CMD> .\\packages\\GlobalPhoneDbgen\\tools\\GlobalPhoneDbgen.exe > db/global_phone.json\r\n\r\n3. Tell GlobalPhone where to find the database:\r\n\r\n ```\r\n GlobalPhone.DbPath = \"db/global_phone.json\";\r\n ```\r\n\r\n## Examples\r\n\r\nParse an international number string into a `GlobalPhone::Number` object:\r\n\r\n```\r\nvar number = GlobalPhone.Parse(\"+1-312-555-1212\");\r\n# => #<GlobalPhone::Number Territory=#<GlobalPhone::Territory CountryCode=1 Name=US> NationalString=\"3125551212\">\r\n```\r\n\r\nQuery the country code and likely territory name of the number:\r\n\r\n```\r\nnumber.CountryCode\r\n# => \"1\"\r\n\r\nnumber.Territory.Name\r\n# => \"US\"\r\n```\r\n\r\nPresent the number in national and international formats:\r\n\r\n```\r\nnumber.NationalFormat\r\n# => \"(312) 555-1212\"\r\n\r\nnumber.InternationalFormat\r\n# => \"+1 312-555-1212\"\r\n```\r\n\r\nIs the number valid? (Note: this is not definitive. For example, the number here is \"IsValid\" by format, but there are no US numbers that start with 555. The `IsValid` method may return false positives, but *should not* return false negatives unless the database is out of date.)\r\n\r\n```\r\nnumber.IsValid\r\n# => true\r\n```\r\n\r\nGet the number's normalized E.164 international string:\r\n\r\n```\r\nnumber.InternationalString\r\n# => \"+13125551212\"\r\n```\r\n\r\nParse a number in national format for a given territory:\r\n\r\n```\r\nnumber = GlobalPhone.Parse(\"(0) 20-7031-3000\", \"gb\");\r\n# => #<GlobalPhone::Number Territory=#<GlobalPhone::Territory CountryCode=44 Name=GB> NationalString=\"2070313000\">\r\n```\r\n\r\nParse an international number using a territory's international dialing prefix:\r\n\r\n```\r\nnumber = GlobalPhone.Parse(\"00 1 3125551212\", \"gb\");\r\n# => #<GlobalPhone::Number Territory=#<GlobalPhone::Territory CountryCode=1 Name=US> NationalString=\"3125551212\">\r\n```\r\n\r\nSet the default territory to Great Britain (territory names are [ISO 3166-1 Alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) codes):\r\n\r\n```\r\nGlobalPhone.DefaultTerritoryName = \"gb\";\r\n# => \"gb\"\r\n\r\nGlobalPhone.Parse(\"(0) 20-7031-3000\");\r\n# => #<GlobalPhone::Number Territory=#<GlobalPhone::Territory CountryCode=44 Name=GB> NationalString=\"2070313000\">\r\n```\r\n\r\nShortcuts for validating a phone number:\r\n\r\n```\r\nGlobalPhone.Validate(\"+1 312-555-1212\");\r\n# => true\r\n\r\nGlobalPhone.Validate(\"+442070313000\");\r\n# => true\r\n\r\nGlobalPhone.Validate(\"(0) 20-7031-3000\");\r\n# => false\r\n\r\nGlobalPhone.Validate(\"(0) 20-7031-3000\", \"gb\");\r\n# => true\r\n```\r\n\r\nShortcuts for normalizing a phone number in E.164 format:\r\n\r\n```\r\nGlobalPhone.Normalize(\"(312) 555-1212\");\r\n# => \"+13125551212\"\r\n\r\nGlobalPhone.Normalize(\"+442070313000\");\r\n# => \"+442070313000\"\r\n\r\nGlobalPhone.Normalize(\"(0) 20-7031-3000\");\r\n# => #<GlobalPhone::FailedToParseNumberException>\r\n\r\nGlobalPhone.Normalize(\"(0) 20-7031-3000\", \"gb\");\r\n# => \"+442070313000\"\r\n```\r\n\r\n## Caveats\r\n\r\nGlobalPhone currently does not parse emergency numbers or SMS short code numbers.\r\n\r\nValidation is not definitive and may return false positives, but *should not* return false negatives unless the database is out of date.\r\n\r\nTerritory heuristics are imprecise. Parsing a number will usually result in the territory being set to the primary territory of the region. For example, Canadian numbers will be parsed with a territory of `US`. (In most cases this does not matter, but if your application needs to perform geolocation using phone numbers, GlobalPhone may not be a good fit.)\r\n\r\n### License\r\n\r\nCopyright © 2013 Sam Stephenson, Oskar Gewalli\r\n\r\nReleased under the MIT license. See [`LICENSE`](LICENSE) for details.\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}