telcolib is a Python library designed for validating phone numbers across multiple countries. Utilizing regular expressions, it ensures phone numbers adhere to specific national formats.
- Validates phone numbers from a wide range of countries.
- Easily extendable to include additional countries and formats.
- Simple, straightforward API.
To install telcolib, run the following command:
pip install telcolibAlternatively, you can clone the repository and install it manually:
git clone https://github.com/copyleftdev/telcolib.git
cd telcolib
pip install .Here's a quick example of how to use telcolib:
from telcolib import PhoneNumberValidator
# Create an instance of the validator
validator = PhoneNumberValidator()
# Validate a phone number
valid = validator.validate('+14445556666', 'USA')
print("Phone number is valid:", valid)To add or update a country's phone number pattern:
validator.add_country_pattern('CountryName', r'^\+CountryCode\d{NumberOfDigits}$')- Python 3.6 or higher.
-
Clone the repository:
git clone https://github.com/copyleftdev/telcolib.git
-
Navigate to the project directory:
cd telcolib -
Install the dependencies:
pip install -r requirements.txt
To run the tests, execute:
pytest tests/Contributions to telcolib are welcome! Feel free to fork the repository and submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or feedback related to telcolib, please open an issue in the GitHub repository.