question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistency between isValidNumber and the valid property of asYouType

See original GitHub issue

Hey!

First of all thank you for providing this alternative to the official library provided by Google.

isValidNumber() returns true for the invalid german phone number ‘123456’ while the valid property of asYouType returns false as expected/desired. isValidNumber() uses parse() internally which strips the national prefix.

If this behavior is desired then I believe it must be documented more clearly in the README.md.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
catamphetaminecommented, Jan 2, 2017

Ok, so I guess it should be false. Seems that isValidNumber currently only validates the national number and doesn’t check the national prefix. I’ll add that check.

0reactions
catamphetaminecommented, Apr 18, 2017

Due to a recent issue I’m reverting this fix https://github.com/halt-hammerzeit/libphonenumber-js/issues/67

“As you type” now no longer provides validation. And 30123456 is considered valid by the official Google demo: https://libphonenumber.appspot.com/phonenumberparser?number=30123456&country=DE

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google-libphonenumber: Parse, format, Store and Validate ...
The "As You Type" formatter is a specialized tool that show the formatting progress as it attempts to discover the right format for...
Read more >
react-phonenr-input - UNPKG
'function') {\n return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf....
Read more >
javascript - Getting true valid number using asYouType in ...
I'm using libphonenumber in react to format and validate phone number (Lebanese number in my case). The valid mask of the Lebanese phone...
Read more >
How to use the libphonenumber-js.isValidNumber function in ...
setState({submitAttempted: true, isError: true}); if (allowSMS && isValidNumber(recipient, country)) { sendToGA("event", { eventCategory: "SMS Modal ...
Read more >
Updated phone formatter (#241) · 6e86c48486 - ocsms - Gitea
lib/vendor/giggsey/libphonenumber-for-php/src/Leniency/Valid.php ... `isValidNumber` - full validation of a phone number for a region using length and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found