node-phonenumber icon indicating copy to clipboard operation
node-phonenumber copied to clipboard

Validate Phonenumber is not working

Open aidonsnous opened this issue 6 years ago • 1 comments

In my application people are submitting they phone by start with + sign. I don't care to know if it is from which country but I care about the number being valid. I tried to do this :

try{
                 var phoneNumber = phoneUtil.parse(phoneNumber,'');

                 if (phoneNumber.isValid()){
                     let phoneNumbInt = phoneUtil.format(phoneNumber, phone.PhoneNumberFormat.INTERNATIONAL);
                     //save the phonenumber to user profile.
                         let result = await query('UPDATE user set tel=? where id=?',[phoneNumbInt,userId]);
                         return true;
                 }else{
                     //
                     return false;
                 }
             }catch(e){
                 console.log(e);
                 return false;
             }

But the application is returning the error saying :

isvalid() is not a function

aidonsnous avatar Mar 07 '18 19:03 aidonsnous

Can you check the response value of variable phoneNumber?

wajatimur avatar Mar 27 '18 10:03 wajatimur