Skip to content

Conversation

@thvdveld
Copy link
Collaborator

Fix the check for a valid phone number and use is_viable when parsing.

The regex from the java implementation for checking if a phone number is viable is

DIGITS + "{" + MIN_LENGTH_FOR_NSN + "}" + "|"
      + "[" + PLUS_CHARS + "]*+(?:[" + VALID_PUNCTUATION + STAR_SIGN + "]*" + DIGITS + "){3,}["
      + VALID_PUNCTUATION + STAR_SIGN + VALID_ALPHA + DIGITS + "]*";

Previously, we were checking if we had 3 consecutive digits before alpha characters. However, between these numbers there could be punctuations as well. Which this PR fixes.

Furthermore, I added the is_viable function to the parse logic such that we only continue parsing viable phone numbers, which fixes #80.

@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.64%. Comparing base (1fd3d17) to head (197feda).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #95      +/-   ##
==========================================
- Coverage   67.81%   67.64%   -0.18%     
==========================================
  Files          18       18              
  Lines        2172     2185      +13     
==========================================
+ Hits         1473     1478       +5     
- Misses        699      707       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rubdos rubdos merged commit e27deb2 into main Oct 15, 2025
9 checks passed
@rubdos rubdos deleted the fix/viable-phone-number branch October 15, 2025 12:19
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.

Email gets successfully parsed as a phone number

3 participants