datafaker icon indicating copy to clipboard operation
datafaker copied to clipboard

Normalized phone_number

Open divinenickname opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] At my job I often use phone_number feature, but I work with phone numbers without any signs (only country code and digits). I have to normalize phone numbers by myself.

Describe the solution you'd like A clear and concise description of what you want to happen. It would be perfect to add new method normalizedPhoneNumber() to PhoneNumber class which returns normalized phone.

Of cource I can implement it by myself

divinenickname avatar May 22 '22 16:05 divinenickname

Completely agree. I was looking at a similar related issue myself, or seems that at the moment it's very inconsistent if the international or local format is used. So I was thinking of keeping the current phone number method, but adding two extra methods, one for international and one for nationally formatted numbers.

We could make these numbers both normalized, as to address both issues at once. Would that work for you?

bodiam avatar May 24 '22 00:05 bodiam

@bodiam yes, sounds good. I’ll research implementation ways at the end of the week

divinenickname avatar May 25 '22 13:05 divinenickname

what do you think about normalizedPhoneNumber(Set<Character> characters2keep) where a user could pass characters with those the user is ok and normalizedPhoneNumber() which removes everything except digits?

e.g. for a phone number (01837) 73 427 normalizedPhoneNumber() returns 0183773427 normalizedPhoneNumber(" ".chars().mapToObj(e -> (char) e).collect(Collectors.toSet())) returns 01837 73 427 normalizedPhoneNumber("()".chars().mapToObj(e -> (char) e).collect(Collectors.toSet())) returns (01837)73427

snuyanzin avatar May 30 '22 10:05 snuyanzin

I'm fine with that, I'm mostly interested in having local numbers and international, like:

020584944 vs +9920584944

bodiam avatar May 30 '22 10:05 bodiam

I think this issue is not a real priority at the moment, so I'm going to close it. Happy to have international and normalized phone numbers if someone is keen picking it up though.

bodiam avatar Sep 16 '22 13:09 bodiam

@bodiam I could take up this task. But, first, I wanted to know in a few words how it should look like. For example, in the .yml files add lists for international and local numbers, and have, for example, two methods phoneNumberInternational and phoneNumberLocal

panilya avatar Sep 16 '22 14:09 panilya

Well, when looking at this:

https://libphonenumber.appspot.com/phonenumberparser?number=%2B61403475700

I thought it might be nice to have something like a national and international format. So yes, two lists or regexes would probably be the way forward, though the buildup of phone numbers is slightly more complex. I'm not really sure yet what it should look like, but if you want to give it a shot, feel free, and happy to help.

bodiam avatar Sep 16 '22 15:09 bodiam