I’m validating user phone numbers in a Python backend and I’ve hit the limits of what regex can do.
Users submit the same number in every format imaginable:
+44 7700 900123
07700 900123
07700900123
(0) 7700-900123
Step 1 was normalizing everything to E.164 (strip non-digits, prepend country code when the user selects one):
def clean_number(raw: str) -> str:
return "".join(ch for ch in raw if ch.isdigit() or ch == "+")
Step 2 was a format check:
pattern = r"^\+?\d{7,15}$"
The problem: this regex happily accepts numbers that are format-valid but fake — +123456789012345 passes, 00000000000 passes. It also can’t tell me:
Whether the number is actually allocated/in service — format-correct is not the same as real
Whether it’s mobile or landline — I’m sending SMS OTP codes, and sending to a landline fails silently in some gateways
Whether the leading zero should be dropped — UK 07700… becomes +447700…, but naively prepending 44 breaks numbers that keep their trunk prefix
I looked at libphonenumber. It handles parsing and formatting well, but its validation is still numbering-plan based (a number can be “possible” without being in service), and its carrier metadata is static prefix data that can lag behind real allocations.
How do services that offer a phone number lookup API validate against actual allocations and return line type and carrier? Is there an open numbering-plan dataset I can build this on myself, or is querying a lookup service the standard production approach?
Context: signup flow, a few hundred validations/day, SMS OTP delivery, Python.
6 posts - 4 participants
Read full topic
| # | Наименование новости | Тональность | Информативность | Дата публикации |
|---|---|---|---|---|
| 1 | How do you stop the same person from signing up again and again on a free plan? | 0 | 7.37 | 16-09-2026 |
| 2 | How should a small service business design a simple booking flow without hurting conversions? | 0 | 8.06 | 21-09-2026 |
| 3 | Best way to build a responsive multi-field booking form? | 0 | 6.38 | 01-10-2026 |
| 4 | Как городской телефон определяет номер? Запускаем Caller ID в домашних условиях | 0 | 7.81 | 25-09-2026 |
| 5 | What’s a sensible way to handle a daily word puzzle backend in PHP? | 0 | 6.62 | 18-09-2026 |
| 6 | Mobile Menu Help | 0 | 8.98 | 02-10-2026 |
| 7 | What makes a small web utility useful and trustworthy? | 0 | 5.33 | 05-10-2026 |
| 8 | Availability of their API hostname OpenCart | 0 | 4.76 | 09-09-2026 |
| 9 | flight registrations | 0 | 20.23 | 28-09-2026 |
| 10 | Эксперт Бедеров: мошенники изолируют жертву от близких для создания вакуума лжи | 0 | 11.53 | 02-10-2026 |