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

phone_number should support different formats #2053

Open
sshishov opened this issue May 29, 2024 · 5 comments
Open

phone_number should support different formats #2053

sshishov opened this issue May 29, 2024 · 5 comments

Comments

@sshishov
Copy link
Contributor

Currently usage of phone_number factory is useless as every time it generates completely different format which is not compatible with third party libraries you want to include it in.

I would recommend to add the format or any other key with pre-defined literals and based on this return the proper format.
I guess the main formats can be like here: https://django-phonenumber-field.readthedocs.io/en/latest/reference.html#phone-number-format-choices

For backward compatibility we can have the format=None as default and fallback to unsorted return value, otherwise all generated phone number fields should be based on some format rule

@fcurella
Copy link
Collaborator

fcurella commented Jun 7, 2024

I'm confused, phone_number does support different formats. See the en_US localization for example.

Are you setting the locale when you instantiate Faker?

@fcurella
Copy link
Collaborator

fcurella commented Jun 7, 2024

After reading your comment on #1588 (comment), I think I see what you're saying.

I'm ok with adding the parameter. Feel free to submit a Pull Request and I'll be happy to review it!

@parsariyahi
Copy link
Contributor

What If we add another method like local_phone_number() where you have the flag like local or just you said format?

@stefan6419846
Copy link
Contributor

Why would we need another method? A format parameter for the existing method is backwards-compatible as well.

@parsariyahi
Copy link
Contributor

The thing is some countries have more that just one format, so we have local and we have format
So let's say I want a number in specific local but the format does not matter.
In this situation just using a format param should work just fine like you said.
But now I want a local phone number with specific format, in here we should use another param with this solution.

One side is, should we have format when we have all localizations handled separately.
But if we say you can use a general phone_number method with a local or country
It's better to handle formats too.

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

No branches or pull requests

4 participants