Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/titarenko/fix-phone
Validate and format phone number, or return nothing, if such phone is not valid.
https://github.com/titarenko/fix-phone
decompose decomposition number phone validate validation
Last synced: about 1 month ago
JSON representation
Validate and format phone number, or return nothing, if such phone is not valid.
- Host: GitHub
- URL: https://github.com/titarenko/fix-phone
- Owner: titarenko
- Created: 2015-12-23T13:04:55.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T17:34:35.000Z (about 2 years ago)
- Last Synced: 2024-11-09T16:47:34.349Z (about 2 months ago)
- Topics: decompose, decomposition, number, phone, validate, validation
- Language: JavaScript
- Homepage:
- Size: 358 KB
- Stars: 4
- Watchers: 3
- Forks: 7
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fix-phone
[![Build Status](https://secure.travis-ci.org/titarenko/fix-phone.png?branch=master)](https://travis-ci.org/titarenko/fix-phone)
[![Coverage Status](https://coveralls.io/repos/github/titarenko/fix-phone/badge.svg?branch=master)](https://coveralls.io/github/titarenko/fix-phone?branch=master)Validate and format phone number, or return nothing, if such phone is not valid.
## Installation
```bash
npm i fix-phone --save
```## Usage
```js
var fix = require('fix-phone');fix('ua', '050-121-22-33'); // returns +380501212233
fix('ua', '010-121-22-33'); // returns nullfix.decompose('ua', '050-121-22-33'); // returns { country: '+380', local: '50', phone: '1212233' }
fix.decompose('ua', '010-121-22-33'); // returns null
```## Supported country codes
Take look at [country modules directory](src/countries).
## Contributors
- [akhll](https://github.com/akhll)
- [MaksimVovk](https://github.com/MaksimVovk)
- [Erushenko](https://github.com/erushenko)
- [turizaz](https://github.com/turizaz)
- [jmakoff](https://github.com/jmakoff)## License
MIT