I'm stumped.
I've messed around with this for a while and it doesn't make sense.
libphonenumber-js does not validate a phone number that should be a valid number. It returns 'false' every time.
This seems pretty simple and straightforward. A 10 digit number from a form field.
const phoneNumber = libphonenumber.parsePhoneNumber(contact_asset, 'US')
if (phoneNumber) {
console.log(libphonenumber.isPossiblePhoneNumber(JSON.stringify(phoneNumber)));
console.log(phoneNumber.formatNational());
}
What seems odd to me is that when I parse the phone number and pass it to the validator, if it's not a string, it complains. I would expect libphonenumber to accept the output of parse without stringifying it.
What am I missing?