Answers for "Mobile Number Parser"

0

Mobile Number Parser

const mobileNumberParaser = numbers => numbers.map((number) => {
  try {
   const phone = phoneUtil.parseAndKeepRawInput(number);
   if (!(phoneUtil.isValidNumber(phone) && phoneUtil.isPossibleNumber(phone))) {
    throw Error(`Invalid phone number: ${phone}`);
   }

   return {
    region: phoneUtil.getRegionCodeForNumber(phone),
    number: phone.getNationalNumber(),
    cc: phone.getCountryCode()
   };
  } catch (e) {
   return Error(e);
  }
 })
Posted by: Guest on August-10-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language