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

Improved handling of invalid mobile numbers #623

Merged
merged 7 commits into from
Oct 9, 2024

Conversation

hggutvik
Copy link
Contributor

@hggutvik hggutvik commented Oct 7, 2024

Description

When placing notification orders where SMS is involved, mobile numbers that include invalid characters (like letters) now produces response code 400 instead of 500. Additionally, the general response for such invalid numbers is changed:

  • Before: "Invalid mobile number format".
  • Now: "Mobile number can contain only '+' and numeric characters, and it must adhere to the E.164 standard."

Affected endpoints:

  • POST /notifications/api/v1/orders/sms
  • POST /notifications/api/v1/orders

The MobileNumberHelper class, used by Validators to perform number validation, now has a try/catch for when PhoneNumberUtil throws NumberParseException. These exceptions now result in the method IsValidMobileNumber returning false.

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@hggutvik hggutvik marked this pull request as ready for review October 7, 2024 13:54
Copy link
Member

@SandGrainOne SandGrainOne left a comment

Choose a reason for hiding this comment

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

Please just add a test for a Norwegian name in the email address.

Copy link

sonarqubecloud bot commented Oct 8, 2024

@hggutvik hggutvik merged commit 0d9e242 into main Oct 9, 2024
5 of 7 checks passed
@hggutvik hggutvik deleted the bugs/improve-mobile-number-validation branch October 9, 2024 08:09
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