i18n Phone Number Validation in Angular

Photo by Sam Parkman on Unsplash

google-libphonenumber

Now, it is time to implement in Angular. You can read https://www.npmjs.com/package/google-libphonenumber for more details about the library.

npm install --save google-libphonenumber
npm install --save-dev @types/google-libphonenumber

libphonenumber-js

There is also another library called “libphonenumber-js” swith more weekly downloads (https://www.npmjs.com/package/libphonenumber-js).

import {
isPossiblePhoneNumber,
isValidPhoneNumber,
validatePhoneNumberLength
} from 'libphonenumber-js'
isValidPhoneNumber('8 (800) 555-35-35', 'RU') === true
import { Metadata } from 'libphonenumber-js'

const metadata = new Metadata()
metadata.selectNumberingPlan('US')

console.log(metadata.numberingPlan.leadingDigits())

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nil Seri

Nil Seri

777 Followers

I would love to change the world, but they won’t give me the source code | coding 👩🏼‍💻 | coffee ☕️ | jazz 🎷 | anime 🐲 | books 📚 | drawing 🎨