node-phonenumber
node-phonenumber copied to clipboard
Validate Phonenumber is not working
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
Can you check the response value of variable phoneNumber?