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

faker.phone.number fails to generate international numbers #3185

Closed
8 of 10 tasks
manchuck opened this issue Oct 15, 2024 · 2 comments
Closed
8 of 10 tasks

faker.phone.number fails to generate international numbers #3185

manchuck opened this issue Oct 15, 2024 · 2 comments
Labels
s: invalid This doesn't seem right wontfix This will not be worked on
Milestone

Comments

@manchuck
Copy link

Pre-Checks

Describe the bug

When using faker.phone.number({ style: 'international' }), a deprecation warning is issued and no number is returned.

Using the code sample the output will be:

warn:     [@faker-js/faker]: faker.phone.number(format) is deprecated since v8.1 and will be removed in v9.0. Please use faker.phone.number(), faker.string.numeric() or faker.helpers.fromRegExp() instead.

International number: 
Number: (538) 625-6227 x991

,

Minimal reproduction code

const InternationalNumber = faker.phone.number({ style: 'international' }) ;
console.log(`International number: ${InternationalNumber}`);
const number = faker.phone.number();
console.log(`Number: ${number}`);

Additional Context

No response

Environment Info

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.45 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.3 - ~/.nvm/versions/node/v18.20.3/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 10.9.0 - ~/.nvm/versions/node/v18.20.3/bin/npm
  Browsers:
    Safari: 17.6
  npmPackages:
    @faker-js/faker: 8.4.1 => 8.4.1

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

npm

@manchuck manchuck added c: bug Something isn't working s: pending triage Pending Triage labels Oct 15, 2024
@xDivisionByZerox
Copy link
Member

You have installed @faker-js/faker: 8.4.1 as you can see by your provided "Environment Info". The style parameter has only been introduced in v9.

You are getting the deprecation message (in v8) because only a single string argument, called format, was present back then:

if (format != null) {
deprecated({
deprecated: 'faker.phone.number(format)',
proposed:
'faker.phone.number(), faker.string.numeric() or faker.helpers.fromRegExp()',
since: '8.1',
until: '9.0',
});
}

Since the if block only checked for != null your argument fulfills this check.


All you need to do is update to v9. If you want to use v8 of Faker refer to the v8 docs: https://v8.fakerjs.dev/api/phone.html#number

@xDivisionByZerox xDivisionByZerox added s: invalid This doesn't seem right wontfix This will not be worked on and removed c: bug Something isn't working s: pending triage Pending Triage labels Oct 15, 2024
@ST-DDT ST-DDT added this to the v8.x milestone Oct 15, 2024
@manchuck
Copy link
Author

@xDivisionByZerox You get all the internet points. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: invalid This doesn't seem right wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants