-
-
Notifications
You must be signed in to change notification settings - Fork 932
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
The faker.phone.number()
is returned differently than in the documentation.
#3283
Comments
The documentation for the default case
The "e.g." means that these are example values. So the function can return many different styles which are all considered human readable. We specifically designed this to return different (but common) styles. That way your system can be tested for potential edge cases. If you need THIS specific pattern, you are free to write your own method: function phoneNumber() {
return `${faker.string.numeric(3)}-${faker.string.numeric(3)}-${faker.string.numeric(4)}`;
} |
Are you referring to the examples? faker.phone.number() // '961-770-7727'
faker.phone.number({ style: 'human' }) // '555.770.7727 x1234'
faker.phone.number({ style: 'national' }) // '(961) 770-7727'
faker.phone.number({ style: 'international' }) // '+15551234567' Currently, the examples only show one example per invocation, as it isn't feasible to provide one for every possible variant, as there might be 10+ per layer of patterns stacking up to millions of combinations per locale. e.g. faker.food.description has 20 patterns with ~4 placeholders each resulting in ~270 Mio possible result values. If you want to get a feeling on what values to expect, then our website overs the ability to execute faker functions in the browser console (or you can do so locally).
Do you have a suggestion on how to do that? |
@ST-DDT I understand that you can't include every example type in your documentation, but can we at least imply that it's not just one type? Someone unfamiliar with fakers might have a hard time predicting based on this documentation alone. Perhaps if I had read the documentation carefully from the beginning, I wouldn't have been so misled. I'm usually the type of person who checks examples first. Sorry if my comment came off as a bit harsh! I wanted to highlight that “human” is the default for faker.phone.number(). This would guide readers to learn about the “human” style. It would also help them see that the function returns more than one type of value. I just thought it would prevent someone like me in the future from getting confused. and if you disagree, feel free to close the PR! |
Thanks for your feedback ❤️ . We will talk about it in the next team meeting. |
Close with #3284. Please see the PR I mentioned to see more detailed discussion. @ST-DDT @xDivisionByZerox Thank you for your kind feedback and It was a pleasure to be a part of this conversation. Hope we can discuss another contribution in the future! |
Pre-Checks
Describe the bug
I read the documentation and thought that faker.phone.number() would return a string of the form xxx-xxx-xxxx, but it doesn't.
Need to supplement the documentation so that readers can fully expect the value returned by
faker.phone.number()
.Minimal reproduction code
Additional Context
No response
Environment Info
Which module system do you use?
Used Package Manager
npm
The text was updated successfully, but these errors were encountered: