0.1.1 • Published 4 years ago

phone-validation v0.1.1

Weekly downloads
43
License
ISC
Repository
github
Last release
4 years ago

Phone Validation module

Module to validate various phone numbers return true for valid phone numbers and false for invalid phone numbers

Installing and using as a dependency

npm install phone-validation --save

Testing

npm run test

Using Package

In order to use the package in your modules,

  • Import the module

    const { isValidPhone } = require('phone-validation')
  • The isValidPhone(phoneNumber) function returns a true or false for valid or invalid phone numbers

    const validPhone = isValidPhone('(+254)-701-123-456');

Sample Validation Table

No.Valid Phone NumbersInvalid Phone Numbers
1.+254 701 123 456-701-123-345
2.+254-701-123-456-701123345
3.254 701 123 456(254) 701 123 456
4.0-701-123-456(+254) 701 123 456
5.0 701 123 456(+254)-701-123-456
6.0701 123 456undefined
7.0701-123-456null
8.0701123456empty string
9.701123456aphabets
10.701123459alphanumerics
11.+255-701-123-456
12.+251 701 123 456
13.+256-701-123-456
14.+541-712-3456
15.1-541-712-3456
16.001-541-712-3456

Reach out

For any concerns, please raise an issue on the repo, or reach out to Charles Okoyoh

Disclaimer

The sample phone numbers used in all of our examples are representative and are not for specific people. Any resemblance to actual phone numbers is purely accidental and/or coincidental.

0.1.1

4 years ago

0.1.0

4 years ago