catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript

Home Page:https://catamphetamine.gitlab.io/libphonenumber-js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

validatePhoneNumberLength does not return TOO_LONG for invalid Ukrainian phone number

davidarny opened this issue · comments

A valid Ukrainian phone number includes 9 digits after +380 country code. I'm validating phone number with libphonenumber-js and getting invalid results when user types 10 digits. Question is why user is able to type 10 digits?

I didn't found any info that Ukrainian phone number can be 10 symbols long (after a country code)

validatePhoneNumberLength("+380 93 111-111") // returns TOO_SHORT - it's ok
validatePhoneNumberLength("+380 93 111-1111") // returns undefined - it's ok
validatePhoneNumberLength("+380 93 111-11111") // returns undefined - it's not ok, should be TOO_LONG
validatePhoneNumberLength("+380 93 111-111111") // returns TOO_LONG - it's ok

Question is why user is able to type 10 digits?

This library doesn't provide any "typing" capabilities

@catamphetamine yeah, I'm using a masking library which relies on validatePhoneNumberLength function to prevent typing too long phone numbers. Sorry for confusion :)

So what's your question then?

validatePhoneNumberLength should return TOO_LONG for such phone number I suppose: +380 93 111-11111. Valid Ukrainian phone number has only 9 digits after +380

@DavidArutiunian See the "bug reporting" section of the readme. There it explains how to check any assumptions using Google's demo.

@DavidArutiunian According to the links you've posted, Google doesn't return TOO_LONG for those numbers so libphonenumber-js behavior is correct.

@DavidArutiunian And when it's too long then it returns TOO_LONG:
https://libphonenumber.appspot.com/phonenumberparser?number=%2B38093111111111

Ok, I see. Thanks for clarification! Closing this issue.