Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle country specific phone number variations ? (ex: prefix zero in some countries) #58

Open
gkpo opened this issue Jan 17, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@gkpo
Copy link

gkpo commented Jan 17, 2024

In France for instance, phone numbers are usually written as:
06 65 11 22 33
The valid equivalent to this number is:
+336 65 11 22 33

Now with react-native-international-phone-number if a user selects France as a country, it will automatically prefix +33 in front of the number. However, not everybody will know that they have to remove the zero prefix when they see +33.
So in my case, I sometimes end up with this number being saved to the database:
+3306 65 11 22 33

Is there a way to handle this kind of country specific variations in user input ? I don't know what variations exist in each country so I'm wondering if this library has something doing this.

I think ideally it would detect that a zero has been inserted, and put it in parenthesis like so:
+33(0)6 65 11 22 33 -> On the user interface
+336 65 11 22 33 -> Saved to the DB

@AstrOOnauta AstrOOnauta added the enhancement New feature or request label Jan 24, 2024
@AstrOOnauta
Copy link
Owner

Hey @gkpo! Thanks for your issue, an interesting point that I wasn't aware of...
I will think about a solution soon...

But, for now..you can remove the 0 (usying substring method) if the phoneNumber started with 0 before saving to your DB.

🚀 AstrOOnauta 🚀

@gkpo
Copy link
Author

gkpo commented Jan 24, 2024

Yes, that's what I ended up doing :) thanks for your work!

@Bilal-Abdeen
Copy link

@AstrOOnauta Thank you for the great library. I would like to add my vote to implement the option to remove zeros inserted between the country code and the local phone number. Some other libraries provide this feature as a method.

Example 1:
https://github.com/thegamenicorus/react-native-phone-input/blob/43d935639a7806b25a9fef15be6c9f6fcd8c88b4/lib/index.js#L166

Example 2:
garganurag893/react-native-phone-number-input#20 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants