Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow generating only mobile numbers for faker.phone.number() #3582

@matthewmayer

Description

@matthewmayer

Clear and concise description of the problem

We've had various requests to restrict faker.phone.number() to only return mobile/cellphone numbers e.g. #2883 and #3574

In many locales phone numbers have a fixed format e.g. in en_GB they are always 07##########. It's common for country-specific websites to require a mobile number for signup.

Suggested solution

A new style "mobile" in the faker.phone.number() method which will return a nationally formatted mobile number with no spaces, e.g. 071234512345 for en_GB or 0812345678 for en_ZA.

In locales where this doesn't make sense e.g. en/en_US where cellphone numbers are indistinguishable from landlines, we would not provide data and this would throw.

Alternative

There is some existing data stored in src/*/cell_phone/formats for some locales however

  • This is not currently exposed in a method, it's only accessible via faker.fake and is undocumented
  • In many cases the data is many years out of date.

The naming could alternatively be say cell or cellphone or nationalMobile

Additional context

I have added a sample PR at #3583

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: featureRequest for new featurem: phoneSomething is referring to the phone modules: pending triagePending Triages: waiting for user interestWaiting for more users interested in this feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions