Skip to content
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

Phone number validation #28

Merged
merged 5 commits into from
May 31, 2024
Merged

Phone number validation #28

merged 5 commits into from
May 31, 2024

Conversation

snshn
Copy link
Contributor

@snshn snshn commented May 28, 2024

Very basic implementation using regular expressions (currently it's literally one regular expression).

Please let me know if this approach seems like the right way to go, and feel free to provide as many different examples as possible — that'll help me construct more regular expressions and write more tests for the validator.

@snshn snshn merged commit 79fa5ec into main May 31, 2024
4 checks passed

phone_number_formats = [
r"^\d{3,11}$", # 911 & 11111111111
r"^(\(?\+\d{1,2}\)?\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$", # +1 (628) 555-3456 & (+1) 415-155-1555
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some phone numbers have multiple international prefxies, does the below work?

Phone Number Dialed Location
456-7890 Local Phone Number
212-456-7890 Domestic
+1-212-456-7890 International Phone Number
1-212-456-7890 Dialed in the US
001-212-456-7890 Dialed in Germany
191-212-456-7890 Dialed in France

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I'll check now, thank you for more examples!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negatronic, only "212-456-7890" worked ; expanding the regex and making a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants