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.77k stars 217 forks source link

Custom formatter functions #295

Closed Ricki-BumbleDev closed 5 years ago

Ricki-BumbleDev commented 5 years ago

In Germany the following phone number format is very common: +49 (0)40 1234567. This combines the national and international format. If the national format is used, the +49 is skipped and the zero must be used. If the international format is used, the +49 is entered and the zero is skipped, which is why the zero is printed in brackets.

Would be cool to have a formatter for this format or to be able to pass a custom formatter function into the format function, that gets called with the different parts of the phone number, that could then be assembled as wished.

catamphetamine commented 5 years ago

Not gonna happen. Such phone number format is invalid.

Ricki-BumbleDev commented 5 years ago

Thanks for your quick response! Whether or not the format is invalid is arguable. Anyways, it doesn't make the format less common. I can understand that any "special" formats shouldn't be added for everyone, however, being able to pass a custom formatter function for such cases would be nice, wouldn't it?

catamphetamine commented 5 years ago

I think it’s better for this library to mimick Google’s API and not extend it with extra features which increase msintenance complexity.

On Sun, 3 Feb 2019 at 22:05, Ricki notifications@github.com wrote:

Thanks for your quick response! Whether or not the format is invalid is arguable. Anyways, it doesn't make the format less common. I can understand that any "special" formats shouldn't be added for everyone, however, being able to pass a custom formatter function for such cases would be nice, wouldn't it?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/catamphetamine/libphonenumber-js/issues/295#issuecomment-460078715, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdH70uSplygxs5dpr0dKnTUnbETQSWjks5vJzMIgaJpZM4aaKrC .