Open hannahwynnjones opened 6 months ago
Hi. No one has ever reported something like that. Supposedly, it could be something with your code. I dunno. I won't be looking into this due to being busy. Also check that you're at the latest version of the lib.
Also, perhaps you're importing parsePhoneNumber
from an incorrect path.
Instead, do this:
import parsePhoneNumber from 'libphonenumber-js/max'
Thanks @catamphetamine for your help - good to know it's likely an issue with my code
I was able to put the code into a 'try' block to remove the errors, like:
// value must be long enough and must be a valid phone number
if (number.length > 1) {
try {
const phoneNumber = parsePhoneNumber(number, countryCode)
number = phoneNumber.formatInternational(countryCode)
} catch (error) {
// do nothing validation will pick this up
}
}
I have also faced this issue. That error is thrown whenever the string you try to validate is too short. So I just added a check before running parsePhoneNumber
like: if (phone.length > 5)
.
Hi,
I've added your libphonenumber-js code like the code snippet below , but I'm getting an angry error in the console and on my page when I don't put a number correctly in first time. This error was caused when I typed 'abc'.
The code works fine since in production the user doesn't see the errors, but we're seeing those errors in Kibana and that's getting very noisy. Is there a way of disabling this error? I would have expected to see this error if i'd have used
parsePhoneNumberWithError
but I'm not.Error: