diff --git a/src/Altinn.Notifications.Core/Helpers/MobileNumberHelper.cs b/src/Altinn.Notifications.Core/Helpers/MobileNumberHelper.cs index f2bd74ca..aeb69802 100644 --- a/src/Altinn.Notifications.Core/Helpers/MobileNumberHelper.cs +++ b/src/Altinn.Notifications.Core/Helpers/MobileNumberHelper.cs @@ -49,8 +49,20 @@ public static bool IsValidMobileNumber(string? mobileNumber) } PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.GetInstance(); + + bool isValidNumber; + + try + { PhoneNumber phoneNumber = phoneNumberUtil.Parse(mobileNumber, null); - return phoneNumberUtil.IsValidNumber(phoneNumber); + isValidNumber = phoneNumberUtil.IsValidNumber(phoneNumber); + } + catch (NumberParseException) + { + isValidNumber = false; + } + + return isValidNumber; } } }