> For the complete documentation index, see [llms.txt](https://hoaitx.gitbook.io/vn-phone-validator/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hoaitx.gitbook.io/vn-phone-validator/master.md).

# VN-PHONE-VALIDATOR

* Compact
* Fast
* Powerful

#### *Note: Only for ten digit number or eleven digit with area code!*

## Installation

requires [Node.js](https://nodejs.org/) v4+ to run.

```bash
$ npm i vn-phone-validator
```

## Use

```javascript
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    // false
```

### Options

**strict**: true/false

```javascript
phoneValidate.validate('0988888888', {strict: true}).isValidate   // true
phoneValidate.validate('0988 888 888', {strict: true}).isValidate // false
```

**format**: string

```javascript
phoneValidate.validate('0988888888', {format: 'xxxx xxx xxx'}).isValidate   // false
phoneValidate.validate('0988888888', {format: '097xxxxxx8'}).isValidate     // false
```

**operator**: array (viettel, vinaphone, mobilephone, vietnamobile, gmobile)

```javascript
phoneValidate.validate('0988888888', {operator: ['vietnamobile']}).isValidate   // false
```

### Function

operator

```javascript
phoneValidate.validate('0988888888').operator()   // viettel
phoneValidate.validate('0123456789').operator()   // false
```

hidden

```javascript
phoneValidate.validate('0988888888').hidden(4, '*') // 098888****
```

format

```javascript
phoneValidate.validate('0988888888').format('xxxx.xxx.xxx')  // 0988.888.888
phoneValidate.validate('0988888888').format('84xxx xxx xxx') // 84988 888 888
```

## Test

```bash
$ npm run test
```

## License

MIT
