https://github.com/crowdcomms/faker-e164
Faker provider to generate E164 Phone Numbers
https://github.com/crowdcomms/faker-e164
python test-data test-data-generator
Last synced: 2 months ago
JSON representation
Faker provider to generate E164 Phone Numbers
- Host: GitHub
- URL: https://github.com/crowdcomms/faker-e164
- Owner: crowdcomms
- License: apache-2.0
- Created: 2017-05-01T05:49:12.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-10-12T07:12:06.000Z (over 3 years ago)
- Last Synced: 2025-08-31T12:52:48.287Z (7 months ago)
- Topics: python, test-data, test-data-generator
- Language: Python
- Size: 25.4 KB
- Stars: 23
- Watchers: 3
- Forks: 10
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Faker Provider for E164 Phone Numbers
`pip install faker-e164`
## Usage
```python
from faker import Faker
from faker_e164.providers import E164Provider
fake = Faker()
fake.add_provider(E164Provider)
# To fake an e164 phone number
fake.e164(region_code="AU", valid=True, possible=True)
# To fake a "safe" e164 phone number from a number of selected regions
fake.safe_e164(region_code="US")
```
## Provider Methods
### e164(*region_code=None*, *valid=True*, *possible=True*) -> *str*
Generate a random phone number for the given `region_code`, if `region_code` is None then a random region will be selected for you. The *valid* and *possible* arguments toggle validation from the [python-phonenumbers](https://github.com/daviddrysdale/python-phonenumbers) library, the relevant methods are [`is_valid_number` and `is_possible_number`](https://github.com/daviddrysdale/python-phonenumbers#example-usage).
### safe_e164(*region_code=None*) -> *str*
Return a phone number from a list of "safe numbers" as per https://fakenumber.org/. Supported regions are "AU", "US", "GB", and "CA".
> _Note:_ GB numbers are treated as invalid by the phonenumbers package, to get around this please use the `region_code` arg. For example: `.safe_e164('AU')`.
## Contributing
Contributions for faker-e164 are welcomed by the community. If you are looking for issues to work on, please visit [the issues tab](https://github.com/crowdcomms/faker-e164/issues). If you have an idea for an improvement, please submit an new issue and allow some time for discussion before starting any work on a PR. If you get stuck please don't hesitate to start a discussion with the project maintainers.