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.

Phone number validation doesn't really work correctly

See original GitHub issue

A UK phone number is of the format +44 1234 123456 (country area number). I only include the spaces here to illustrate the format.

It won’t accept as valid even if you give the country code as 0044. I’ve also tried it with my Polish phone number and it won’t accept that either.

I’ve just noticed that the regex is in the code sample itself:

questions = [
  inquirer.Text('name', message="What's your name"),
  inquirer.Text('surname', message="What's your surname"),
  inquirer.Text('phone', message="What's your phone number",
                validate=lambda x, _: re.match('\d+', x),
                )
]

However, there’s no value I seem to be able to give it that will pass validation. I haven’t forgotten to import re.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
magmaxcommented, Jun 2, 2017

I see… You mean in the documentation. Good point. I’ll try to fix it as soon as I could.

0reactions
AuHaucommented, Apr 25, 2019

Ehm, validate=True means it is always valid, sooo nothing interesting there. Otherwise, the validate function is called with signature validate(previous_answers, current_value_of_current_question), therefore you are interested in the second argument 😉 I tried the current example in master and it worked as expected, that said it is not somehow advanced validation it just shows how it works…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't verify phone number - Android - Google Duo Help
Make sure your phone number was entered correctly with the right country code. Step 2: Check for a good Wi-Fi or mobile data...
Read more >
Phone number validation Android - Stack Overflow
Use isGlobalPhoneNumber() method of PhoneNumberUtils to detect whether a number is valid phone number or not. Example.
Read more >
Bad Practices on Phone Number Form Fields - UX Movement
Your users should not wonder which phone number format is valid or get a validation error for the wrong phone number format.
Read more >
Phone Number Validation: Verify Numbers in 3 Seconds
Use our easy-to-use phone number verification tool to expand your contact database and validate phone numbers before you reach out to customers.
Read more >
Working with Angular 4 Forms: Nesting and Input Validation
Validating user inputs is an essential part of any robust web application. Angular 4 makes it especially easy for both template-driven and reactive...
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