# 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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hoaitx.gitbook.io/vn-phone-validator/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
