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

Never include zeroes within a multi-digit number string. #181

Conversation

mecampbellsoup
Copy link

For example, the string "0123456789" exhibits strange behavior when parsing as a phone number. The leading zero often gets thrown out.

@hmaack
Copy link
Member

hmaack commented Mar 23, 2015

Hi @mecampbellsoup, thanks for your PR. Phone number can contain leading zeros, what is the issue?
German number e.g. 0174 123 4567 89 or international german number 0049 174 123 4567 89 .

@mecampbellsoup
Copy link
Author

In our case we are using the phone gem and seeing strange behavior (read: intermittent random test failures) because of this:

ruby-2.2.1-p85 (main):0 > phone_obj = Phoner::Phone.parse("012-345-6789")
#<Phoner::Phone:0x007ff29217e698 @number="456789", @area_code="123", @country_code="1", @extension=nil>
ruby-2.2.1-p85 (main):0 > phone_obj.number
"456789"

... where the "012-345-6789" is the phone number string that's randomly generated in our test suite.

Just not sure what the benefit is to having the random multi-digit number string generator include zeroes.

@rstacruz
Copy link
Contributor

rstacruz commented May 4, 2015

This seems like a problem with the phone gem. Here's a german phone number, 01806 882 663.
"01806" is actually an area code and this was parsed wrong.

> Phoner::Phone.parse('01806 882 663', country_code: '49')
 @area_code="180",
 @country_code="49",
 @extension=nil,
 @number="6882663">

but then again, the US has no area codes < 200 (i may be wrong), so if FFaker::PhoneNumber was targeting US numbers, it should probably have that restriction.

rstacruz added a commit that referenced this pull request May 12, 2015
Ensure that PhoneNumber does not throw invalid US area codes
@marocchino
Copy link
Member

Maybe can we close this?

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

Successfully merging this pull request may close these issues.

None yet

4 participants