wajatimur / node-phonenumber

Google's phone number handling library ported to Node
33 stars 5 forks source link

Validate Phonenumber is not working #21

Open aidonsnous opened 6 years ago

aidonsnous commented 6 years ago

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

wajatimur commented 6 years ago

Can you check the response value of variable phoneNumber?