-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Faker::PhoneNumber.cell_phone not enforcing locale #499
Comments
I can't seem to reproduce this issue. First, I require faker and then set the locale to en-US. I then made a loop that runs 10,000 times (and even tried it multiple times) and store the result of called Faker::PhoneNumber.cell_phone into a variable called num. I then use a regular expression to search for the first occurrence of 3 digits (\d{3}) then inspect the first match and first character checking for a "1". If it is found, it outputs the full phone number.
I also inspected the code: phone_number.rb and faker.rb. In phone_number.rb, the code for cell_phone and phone_number are almost identical...it's just that cell_phone has different (less) formats to not include extensions and the such. Both cell_phone and phone_number call phone_number.area_code:
which calls faker.fetch which takes a "sample" (random element from the Array). This Array contains the following values:
|
This doesn't change my investigation, just wanted to me a little more clear. |
I haven't really tried to debug why, but the code you used to search does not return any results for me.
However, a simple
suffices to confirm the issue for me returning, eg:
|
Looks like the problem is that the default locale is The
Which allows any number as the first in an area code. This suggests the fix is setting your locale to |
Looks like this a duplicate issue of #24 . Suggest closing in favor of that one. |
I see. Looks like with the locale set this issue is not an issue.... closing. |
which faker version are you using? @serhiiperfectial could you provide a sample application? |
@serhiiperfectial Your piece of code isn't ruby. Are you sure that you're in the correct repo? |
Yeah, sorry. It's Java code... and wrong project. Sorry. I'll direct my question to the one that I'm using. Sorry again |
I've noticed that when you use the cell phone method after setting the locale, it does not enforce the area code rules. notice in the code sample below, the first result is area code, "126" which is invalid.
The text was updated successfully, but these errors were encountered: