catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.8k stars 216 forks source link

Feature request: international template for a given country #422

Closed benramsay closed 2 years ago

benramsay commented 2 years ago

Is it possible to have the international template, giving the country code ? This is sometimes necessary to guide the user like adding a placeholder string. Some function like : getInternationalTemplate("US") => +1 xxx xxx xxxx

To have one of the possible templates, is this the "best" (or a good) way to do it


    const formatter = new AsYouType(country.code);
    formatter.input(country.dial_code);
    let template= formatter.formatter.template;
    template= country.dial_code + template.slice(country.dial_code.length);
catamphetamine commented 2 years ago

There're many templates in a country.