Skip to main content

Production-ready Python library for email and phone number validation. Validate emails and phone numbers with support for multiple countries. Built by Skyweb IT Solutions Private Limited.

Project description

phone-and-mail-verifier

A simple, production-ready Python package for validating email addresses and phone numbers. Built by Skyweb IT Solutions Private Limited - your trusted partner for software development solutions.

Website: https://www.skywebdev.xyz | Email: official@skywebdev.xyz

Features

  • Email Validation: Validate email addresses using regex patterns
  • Phone Validation: Validate phone numbers using the phonenumbers library
  • Country Support: Default country is India (IN), but supports any country code
  • Clean API: Simple and intuitive functions
  • Well Tested: Comprehensive unit tests included
  • Production Ready: Follows Python packaging best practices

Installation

pip install phone-and-mail-verifier==0.1.2

Quick Start

from email_phone_validator import validate_email, validate_phone

# Validate email
print(validate_email("test@gmail.com"))      # True
print(validate_email("invalid.email"))       # False

# Validate phone (default country: India)
print(validate_phone("9876543210"))          # True
print(validate_phone("+919876543210"))       # True
print(validate_phone("12345"))               # False

# Validate phone for other countries
print(validate_phone("+12025551234", "US"))  # True
print(validate_phone("2025551234", "US"))    # True

Usage Examples

Email Validation

from email_phone_validator import validate_email

# Valid emails
validate_email("user@example.com")           # True
validate_email("john.doe@company.co.uk")     # True
validate_email("user+tag@example.com")       # True

# Invalid emails
validate_email("invalid.email")              # False
validate_email("@example.com")               # False
validate_email("user@")                      # False

Phone Validation

from email_phone_validator import validate_phone

# Indian phone numbers (default country)
validate_phone("9876543210")                 # True
validate_phone("+919876543210")              # True
validate_phone("919876543210")               # True

# US phone numbers
validate_phone("+12025551234", "US")         # True
validate_phone("2025551234", "US")           # True

# UK phone numbers
validate_phone("+447911123456", "GB")        # True
validate_phone("07911123456", "GB")          # True

# Invalid phone numbers
validate_phone("12345", "IN")                # False
validate_phone("abc1234567", "IN")           # False

Combined Usage

from email_phone_validator import validate_email, validate_phone

def validate_user_data(email, phone, country="IN"):
    """Validate user email and phone number."""
    email_valid = validate_email(email)
    phone_valid = validate_phone(phone, country)
    
    if email_valid and phone_valid:
        return True, "All validations passed"
    else:
        errors = []
        if not email_valid:
            errors.append("Invalid email address")
        if not phone_valid:
            errors.append("Invalid phone number")
        return False, ", ".join(errors)

# Example usage
is_valid, message = validate_user_data(
    email="user@example.com",
    phone="9876543210",
    country="IN"
)
print(f"Validation: {is_valid}, Message: {message}")

API Reference

validate_email(email: str) -> bool

Validates an email address using regex patterns.

Parameters:

  • email (str): The email address to validate

Returns:

  • bool: True if the email is valid, False otherwise

validate_phone(phone: str, country: str = "IN") -> bool

Validates a phone number for a given country using the phonenumbers library.

Parameters:

  • phone (str): The phone number to validate (can be with or without country code)
  • country (str): ISO country code (default: "IN" for India)
    • Examples: "US", "GB", "IN", "AU", "CA", etc.

Returns:

  • bool: True if the phone number is valid, False otherwise

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/Skywebsite/phone-and-mail-verifier.git
cd phone-and-mail-verifier

# Install in development mode
pip install -e .

# Install development dependencies
pip install -e ".[dev]"

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=email_phone_validator

# Run specific test file
pytest tests/test_email.py
pytest tests/test_phone.py

Building the Package

# Install build tools
pip install build twine

# Build the package
python -m build

# This creates:
# - dist/phone_and_mail_verifier-0.1.2.tar.gz
# - dist/phone_and_mail_verifier-0.1.2-py3-none-any.whl

Publishing to PyPI

  1. Create a PyPI account: https://pypi.org/account/register/

  2. Upload the package:

    twine upload dist/*
    
  3. Test the installation:

    pip install phone-and-mail-verifier==0.1.2
    

Requirements

  • Python >= 3.7
  • phonenumbers >= 8.13.0

Supported Countries

The phone validation supports all countries supported by the phonenumbers library, including but not limited to:

  • India (IN) - Default
  • United States (US)
  • United Kingdom (GB)
  • Australia (AU)
  • Canada (CA)
  • And many more...

For a complete list, refer to the phonenumbers library documentation.

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author & Company

Skyweb IT Solutions Private Limited

We specialize in creating robust, production-ready software solutions. This package is part of our commitment to providing high-quality open-source tools for the developer community.

Acknowledgments


Need custom software solutions? Contact us at official@skywebdev.xyz or visit https://www.skywebdev.xyz

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phone_and_mail_verifier-0.1.2.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phone_and_mail_verifier-0.1.2-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file phone_and_mail_verifier-0.1.2.tar.gz.

File metadata

  • Download URL: phone_and_mail_verifier-0.1.2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for phone_and_mail_verifier-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ee984178a49b0460a0a57f96b5d2d9e9d26c00e0b0ff56c5c27240060a335f27
MD5 4a427c773895104f50298c004e1c9a31
BLAKE2b-256 6feb90a298f95cff403f590f482ddd17df90e908e76cdf34d6ba71ca1ede763a

See more details on using hashes here.

Provenance

The following attestation bundles were made for phone_and_mail_verifier-0.1.2.tar.gz:

Publisher: workflow.yml on Skywebsite/phone-and-mail-verifier

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phone_and_mail_verifier-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for phone_and_mail_verifier-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f639d8e6852cf705f23362a08c1a8b2ba11d1c145aec62d961fcb3f32ca878fd
MD5 95223ccd74f3493a11c62fb5931ed546
BLAKE2b-256 84736ee440085da3508c57e7a1112d19a8ef34a1e4b53bb524ee8081b73b0f44

See more details on using hashes here.

Provenance

The following attestation bundles were made for phone_and_mail_verifier-0.1.2-py3-none-any.whl:

Publisher: workflow.yml on Skywebsite/phone-and-mail-verifier

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page