Socket
Book a DemoInstallSign in
Socket

joi-phone-number-validation

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi-phone-number-validation

Joi Phone Number is validation rule for Joi

1.0.2
latest
npmnpm
Version published
Maintainers
0
Created
Source

Joi Phone Number

Joi Phone Number is validation rule for Joi.

Latest Stable Version License NPM Downloads NPM Downloads

Installation

$ npm i joi-phone-number-validation

Usage

const { JoiPhoneNumber, RETURNING_FORMAT } = require("joi-phone-number-validation");

const schema = JoiPhoneNumber.string().phoneNumber({
  returningFormat: RETURNING_FORMAT.NATIONAL,
});
const { value, error } = schema.validate('+2010 605 944 88');   // 010 60594488

const schema = JoiPhoneNumber.string().phoneNumber({
  returningFormat: RETURNING_FORMAT.INTERNATIONAL,
});
const { value, error } = schema.validate('+2010 605 944 88');   // +20 10 60594488

const schema = JoiPhoneNumber.string().phoneNumber({
  returningFormat: RETURNING_FORMAT.ORIGINAL,
});
const { value, error } = schema.validate('+2010 605 944 88');   // +2010 605 944 88

const schema = JoiPhoneNumber.string().phoneNumber({
  returningFormat: RETURNING_FORMAT.FORMATTED_VALUE,
});
const { value, error } = schema.validate('+2010 605 944 88');   // +201060594488

const schema = JoiPhoneNumber.string().phoneNumber({
  returningFormat: RETURNING_FORMAT.RFC3966,
});
const { value, error } = schema.validate('+2010 605 944 88');   // tel:+201060594488

const schema = JoiPhoneNumber.string().phoneNumber({
  returningFormat: RETURNING_FORMAT['E.164'],
});
const { value, error } = schema.validate('+2010 605 944 88');   // +201060594488

const schema = JoiPhoneNumber.string().phoneNumber({
  returningFormat: RETURNING_FORMAT.VALUE_WITH_EXTRA_INFO,
});
const { value, error } = schema.validate('+2010 605 944 88');   
/*
output: {
        countryCode: 'EG',
        formattedNumber: '+201060594488',
        nationalNumber: '1060594488',
        originalValue: '+2010 605 944 88',
        countryCallingCode: '20',
      }
*/

Tests

To run the test suite, first install the dependencies then run npm test:

$ npm install
$ npm test

Support

Feel free to open issues on github.

Keywords

joi

FAQs

Package last updated on 11 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.