phone
- Version 3.1.53
- Published
- 87.3 kB
- No dependencies
- MIT license
Install
npm i phone
yarn add phone
pnpm add phone
Overview
With a given country and phone number, validate and format the phone number to E.164 standard
Index
Variables
variable countryPhoneData
const countryPhoneData: { alpha2: string; alpha3: string; country_code: string; country_name: string; mobile_begin_with: string[]; phone_number_lengths: number[];}[];
Functions
function phone
phone: ( phoneNumber: string, { country, validateMobilePrefix, strictDetection, }?: { country?: string; validateMobilePrefix?: boolean; strictDetection?: boolean; }) => PhoneResult;
{Object} Option {string=} country - country code in ISO3166 alpha 2 or 3 {boolean=} validateMobilePrefix - true to validate phone number prefix {boolean=} strictDetection - true to disable remove truck code and detection logic
Parameter phoneNumber
phone number
Parameter option
Returns
{{phoneNumber: string|null, countryIso2: string|null, countryIso3: string|null}}
Interfaces
interface PhoneInvalidResult
interface PhoneInvalidResult {}
property countryCode
countryCode: null;
property countryIso2
countryIso2: null;
property countryIso3
countryIso3: null;
property isValid
isValid: false;
property phoneNumber
phoneNumber: null;
interface PhoneValidResult
interface PhoneValidResult {}
property countryCode
countryCode: string;
property countryIso2
countryIso2: string;
property countryIso3
countryIso3: string;
property isValid
isValid: true;
property phoneNumber
phoneNumber: string;
Type Aliases
type PhoneResult
type PhoneResult = PhoneInvalidResult | PhoneValidResult;
Package Files (2)
Dependencies (0)
No dependencies.
Dev Dependencies (25)
- @babel/preset-env
- @types/jest
- @types/node
- @types/papaparse
- babel-cli
- babel-loader
- babel-minify-webpack-plugin
- babel-polyfill
- babel-preset-env
- dotenv
- eslint
- eslint-config-aftership
- eslint-plugin-import
- idempotent-babel-polyfill
- jest
- lodash
- papaparse
- rimraf
- ts-jest
- ts-node
- twilio
- typescript
- webpack
- webpack-cli
- webpack-dev-server
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/phone
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/phone)
- HTML<a href="https://www.jsdocs.io/package/phone"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 1986 ms. - Missing or incorrect documentation? Open an issue for this package.