Last updated
Common Validation Mistakes to Avoid
- Using regex alone — patterns like
^\d{10}$accept invalid number ranges and reject valid international formats - Not storing E.164 — inconsistent formats cause duplicates and break telephony API integrations
- Ignoring number type — sending SMS to landlines wastes money and degrades user experience
- Hardcoding country assumptions — always support international formats even for primarily domestic applications
- Not handling extensions — some business numbers include extensions like +1 415 555 0100 ext. 204
Examples
Example 1: Validating a US Phone Number
Input a US number in various formats — all are accepted and normalized:
Input: (555) 867-5309
Country: US (auto-detected)
Result:
Valid: Yes
Type: Mobile
Country: United States (+1)
E.164 Format: +15558675309
National Format: (555) 867-5309
International Format: +1 555-867-5309
The validator normalizes parentheses, dashes, and spaces before checking validity, so formatting differences never cause false negatives.
Example 2: Validating a UK Phone Number
Input: 07911 123456
Country: GB (auto-detected)
Result:
Valid: Yes
Type: Mobile
Country: United Kingdom (+44)
E.164 Format: +447911123456
National Format: 07911 123456
International Format: +44 7911 123456
UK mobile numbers start with 07 in national format but are stored as +447 in E.164. The validator handles this conversion automatically.
Example 3: Validating a German Phone Number
Input: +49 30 12345678
Country: DE
Result:
Valid: Yes
Type: Fixed Line (Landline)
Country: Germany (+49)
E.164 Format: +493012345678
National Format: 030 12345678
International Format: +49 30 12345678
Germany uses different formats for mobile (starting with 015x, 016x, 017x) and landline numbers. The type detection correctly identifies this as a Berlin landline.