Skip to content

Commit

Permalink
fix: show different error message for empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
kaungmyatlwin committed Jan 14, 2023
1 parent 1975dd6 commit d7aafb6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions myanmar-phonenumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@

// Removes trailing spaces, dashes and double country codes
myanmarPhoneNumber.sanitizeInput = function (phoneNumber) {
if (!phoneNumber || phoneNumber.length === 0) {
phoneNumber = phoneNumber.trim();

if (phoneNumber.length === 0) {
return new Error('Phone number is empty.');
}

if (!phoneNumber) {
return new Error('Please include phoneNumber parameter.');
}

phoneNumber = phoneNumber.trim();
phoneNumber = phoneNumber.replace(/[- )(]/g,'')

var countryCodeRe = /^\+?950?9\d+$/;
Expand Down

0 comments on commit d7aafb6

Please sign in to comment.