Skip to content

Add phone number validator using regex #12807

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ShashankChilukuri
Copy link

This pull request adds a new algorithm to validate Indian 10-digit phone numbers using regular expressions.

✅ The function uses Python's re.fullmatch() to match valid phone numbers.

✅ It checks that the phone number starts with 6, 7, 8, or 9 and contains exactly 10 digits.

✅ The function is defined as validate_phone_number(phone: str) -> bool.

✅ It includes multiple doctests for automatic validation.

✅ The file is located in strings/phone_number_validator.py and follows the project’s coding and contribution standards.

This function is useful for basic input validation in form processors, mobile apps, and backend systems that deal with Indian users.

@algorithms-keeper algorithms-keeper bot added tests are failing Do not merge until tests pass labels Jun 23, 2025
@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reviews This PR is ready to be reviewed tests are failing Do not merge until tests pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants