This repository has been archived by the owner on Jun 10, 2018. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi. I don't know if this is a great way to fix this problem, but I thought I'd take a swing at it and see what you thought.
The problem: an invalid number is counted as valid because anchors (^, $) are ignored on a regular expression. I think this happens because the regex also has an OR / pipe operator ( | ).
Example:
Guatemala has eight digit phone numbers, but the number 5555 1234 123 still got through the matcher.
The regex:
/^[2-7]\d{7}|1[89]\d{9}$/
As you can see, the number does not match either of the sides of the expression delimited by the pipe. Probably, it should all be wrapped in parentheses or something. But, I don't want to change all the libphonenumber regex's to solve the problem, because then I can't update from their database very easily.
The solution is completely invalid if there are times that a partial match in the sections I have changed will happen. This was somewhat unclear to me, but I believe that at these points, we are matching the entire number.
Thanks.