VN-PHONE-VALIDATOR
vn-phone-validator is a package support validate mobile phone number for five operator in Viet Nam, includes Viettel, Mobiphone, Vinaphone, Vietnamobile and Gmobile.
Compact
Fast
Powerful
Note: Only for ten digit number or eleven digit with area code!
Installation
requires Node.js v4+ to run.
$ npm i vn-phone-validatorUse
const phoneValidate = require('vn-phone-validator')
phoneValidate.validate('0988888888').isValidate // true
phoneValidate.validate('0988 888 888').isValidate // true
phoneValidate.validate('84988 888 888').isValidate // true
phoneValidate.validate('0123456789').isValidate // falseOptions
strict: true/false
phoneValidate.validate('0988888888', {strict: true}).isValidate // true
phoneValidate.validate('0988 888 888', {strict: true}).isValidate // falseformat: string
phoneValidate.validate('0988888888', {format: 'xxxx xxx xxx'}).isValidate // false
phoneValidate.validate('0988888888', {format: '097xxxxxx8'}).isValidate // falseoperator: array (viettel, vinaphone, mobilephone, vietnamobile, gmobile)
phoneValidate.validate('0988888888', {operator: ['vietnamobile']}).isValidate // falseFunction
operator
phoneValidate.validate('0988888888').operator() // viettel
phoneValidate.validate('0123456789').operator() // falsehidden
phoneValidate.validate('0988888888').hidden(4, '*') // 098888****format
phoneValidate.validate('0988888888').format('xxxx.xxx.xxx') // 0988.888.888
phoneValidate.validate('0988888888').format('84xxx xxx xxx') // 84988 888 888Test
$ npm run testLicense
MIT
Last updated
Was this helpful?