phone

  • Version 3.1.45
  • Published
  • 87 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)

                              Peer Dependencies (0)

                              No peer dependencies.

                              Badge

                              To add a badge like this onejsDocs.io badgeto 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>