/fix-phone

Validate and format phone number, or return nothing, if such phone is not valid.

Primary LanguageJavaScript

fix-phone

Build Status Coverage Status

Validate and format phone number, or return nothing, if such phone is not valid.

Installation

npm i fix-phone --save

Usage

var fix = require('fix-phone');

fix('ua', '050-121-22-33'); // returns +380501212233
fix('ua', '010-121-22-33'); // returns null

fix.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.

Contributors

License

MIT