Comparing version 3.1.0 to 3.1.1
import countryPhoneData from './data/country_phone_data'; | ||
interface PhoneInvalidResult { | ||
isValid: false; | ||
phoneNumber: null; | ||
countryIso2: null; | ||
countryIso3: null; | ||
countryCode: null; | ||
} | ||
@@ -5,0 +9,0 @@ interface PhoneValidResult { |
@@ -22,3 +22,7 @@ "use strict"; | ||
const invalidResult = { | ||
isValid: false | ||
isValid: false, | ||
phoneNumber: null, | ||
countryIso2: null, | ||
countryIso3: null, | ||
countryCode: null | ||
}; | ||
@@ -25,0 +29,0 @@ let processedPhoneNumber = (typeof phoneNumber !== 'string') ? '' : phoneNumber.trim(); |
{ | ||
"name": "phone", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "With a given country and phone number, validate and format the phone number to E.164 standard", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -184,3 +184,3 @@ # Phone · [![Build Status](https://travis-ci.org/AfterShip/phone.svg?branch=v2)](https://travis-ci.org/AfterShip/phone) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com) | ||
```javascript | ||
```typescript | ||
const {phone} = require('phone'); | ||
@@ -191,19 +191,3 @@ | ||
import {phone} from 'phone'; | ||
``` | ||
```typescript | ||
interface PhoneInvalidResult { | ||
isValid: false; | ||
} | ||
interface PhoneValidResult { | ||
isValid: true; | ||
phoneNumber: string; | ||
countryIso2: string; | ||
countryIso3: string; | ||
countryCode: string; | ||
} | ||
type PhoneResult = PhoneInvalidResult | PhoneValidResult; | ||
phone(phoneNumber: string, { country, validateMobilePrefix, strictDetection }?: { | ||
@@ -213,3 +197,3 @@ country?: string; | ||
strictDetection?: boolean; | ||
}): PhoneResult | ||
}) | ||
``` | ||
@@ -228,5 +212,6 @@ | ||
#### Valid result | ||
```javascript | ||
{ | ||
```typescript | ||
type PhoneResult = PhoneInvalidResult | PhoneValidResult; | ||
interface PhoneValidResult { | ||
isValid: true; | ||
@@ -238,2 +223,10 @@ phoneNumber: string; | ||
} | ||
interface PhoneInvalidResult { | ||
isValid: false; | ||
phoneNumber: null; | ||
countryIso2: null; | ||
countryIso3: null; | ||
countryCode: null; | ||
} | ||
``` | ||
@@ -249,15 +242,2 @@ | ||
#### Invalid result | ||
```javascript | ||
{ | ||
isValid: false; | ||
} | ||
``` | ||
Parameter | Type | Description | ||
--- | --- | --- | ||
isValid | Boolean | To indicate if the result valid | ||
[comment]: <> (## Demo) | ||
@@ -267,3 +247,2 @@ | ||
## Test | ||
@@ -329,6 +308,7 @@ | ||
Version | Interface | ||
--- | --- | ||
v2 | [phoneNumber, country] | ||
v3 | {isValid: false} or {isValid: true, phoneNumber: string, countryIso2: string, countryIso3: string, countryCode: string} | ||
Version | Result | Interface | ||
--- | --- | --- | ||
v2 | - | [phoneNumber, country] | ||
v3 | Valid | {isValid: true, phoneNumber: string, countryIso2: string, countryIso3: string, countryCode: string} | ||
v3 | Invalid | {isValid: false, phoneNumber: null, countryIso2: null, countryIso3: null, countryCode: null} | ||
@@ -335,0 +315,0 @@ #### allowLandline vs validateMobilePrefix |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84980
2283
328