-
Notifications
You must be signed in to change notification settings - Fork 100
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
fix: Skip phone number validation when country code is unknown #1062
Conversation
This contribution does not follow the conventions set by the Google Java style guide. Please run the following command line at the root of the project to fix formatting errors: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
// The below format fails validation without a known country code, so check that we skip | ||
// validation when country | ||
// code is unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please merge the last two lines and put a full stop at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that! Not sure why the code formatter split the lines, but it's fixed now with the period too in 5223228.
@@ -93,6 +93,11 @@ public void validateEmail( | |||
@Override | |||
public void validatePhoneNumber( | |||
String phoneNumber, GtfsCellContext cellContext, NoticeContainer noticeContainer) { | |||
if (countryCode.isUnknown()) { | |||
// If the user didn't provide a country code or the provided country-code was invalid, skip | |||
// validation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put a full stop at the end of comments. They must be complete sentences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 5223228.
Thanks for working on that @barbeau, it seems that some unit test failed though: https://github.com/MobilityData/gtfs-validator/runs/4170664366?check_suite_focus=true. |
We shouldn't be declaring any phone numbers invalid when an unknown country code is provided.
@lionel-nj Whoops, I accidentally restored that test in my original commit when testing locally - it should be removed because we don't want to run validation on unknown country codes. I removed it in 381683c so it should pass now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After analyzing the validation reports produced by https://github.com/MobilityData/gtfs-validator/actions/runs/1446146385 - I confirm that no more InvalidPhoneNumberNotice
is triggered. Thanks for fixing #1058 @barbeau!
Summary:
This PR ensures that phone number validation is skipped when country code is unknown (invalid or unprovided). Adds a unit test for this case as well.
Closes #1058.
Background:
The intent of making the country code optional in PR #851 was to skip phone number validation if country code wasn't provided at the command line. Apparently in the main branch phone number validation is run even when the country code is not provided or unknown.
I'm not sure if there was a regression (perhaps in PR #862?) or if we just didn't have sufficient unit test coverage initially to check all cases.
In the main branch we currently have a test:
...but this test doesn't cover this case and it still passes on the main branch. Evidently the phone number validation library considers
+1 (650) 253-0000
a valid phone number even when no valid country code is provided (I'm assuming because it's an international format).However, the phone number validation library does consider other formats (e.g., common US format
813-254-4278
) invalid without a country code.I've added another assertion to check an unknown country code with the US format, and this assertation fails on the current master branch but passes on this PR.
Expected behavior:
When country code is not provided at the command-line, phone number validation should be skipped.
Please make sure these boxes are checked before submitting your pull request - thanks!
gradle test
to make sure you didn't break anything