Skip to content

Commit

Permalink
Add more prominent note about parsing requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
ruimarinho committed Aug 16, 2020
1 parent f56e3da commit 79f5dff
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -30,6 +30,22 @@ npm install --save-prod google-libphonenumber

The following is a simple phone information extraction example similar to what can be viewed on the official demo page.

⚠️ _Most libphonenumber functions expect to receive an instance of `libphonenumber.PhoneNumber` which can be obtained by calling `phoneUtil.parse` or `phoneUtil.parseAndKeepRawInput` on a raw (string) number, otherwise it will throw errors like `TypeError: a.getCountryCodeOrDefault is not a function`._

This **will** work:

```js
phoneUtil.isValidNumberForRegion(phoneUtil.parse('202-456-1414', 'US'), 'US');
```

This **will not** work:

```js
phoneUtil.isValidNumberForRegion('202-456-1414', 'US');
```

More API examples after parsing the raw string:

```js
// Require `PhoneNumberFormat`.
const PNF = require('google-libphonenumber').PhoneNumberFormat;
Expand Down

0 comments on commit 79f5dff

Please sign in to comment.