libphonenumber-js icon indicating copy to clipboard operation
libphonenumber-js copied to clipboard

isValid() and e164 format

Open sbungert-mms opened this issue 2 years ago • 1 comments

Is there any function like isValid that will validate a phone number as being compliant for E164?

E164 numbers need to have at most 15 numbers and no special chars except a leading +, how can I validate that there are not too many digits? Is there some API method of doing this? Or should manually check if there are not to many digits?

validatePhoneNumberLength seems to require a country code and makes sure the phonenumber is within the bounds of a country specific number, but for E164 I don't need to know about the country. I just want to check that there are not more than 15 digits

sbungert-mms avatar Mar 08 '22 14:03 sbungert-mms

E164 numbers need to have at most 15 numbers and no special chars except a leading +

Can you provide a reference to a reputable source?

how can I validate that there are not too many digits? Is there some API method of doing this?

Currently there's no restriction on such phone numbers' length.

but for E164 I don't need to know about the country.

That's true.

catamphetamine avatar Mar 08 '22 20:03 catamphetamine

@catamphetamine I have the same request. Please check my sandbox here https://codesandbox.io/s/libphonenumber-js-e-164-iyhlrx For reference on E.164, check https://www.itu.int/rec/T-REC-E.164-201011-I/en

I hope this can be fixed.

hanselsen avatar Nov 30 '22 10:11 hanselsen

@hanselsen

I have the same request.

What request?

catamphetamine avatar Nov 30 '22 11:11 catamphetamine

@catamphetamine to have the isValidPhoneNumber take the 15 digit number into consideration. That would be great.

hanselsen avatar Nov 30 '22 12:11 hanselsen