UNPKG

test-numbers-generator

Version:

Generate and validate European test phone numbers (mobile and landline) in safe, non-existent ranges.

98 lines (93 loc) 3.48 kB
// src/landlineNumberGenerators.ts // Generator functions for European test landline numbers import { SupportedCountry } from './mobileNumberGenerators'; export const generateTestLandlineNumber: Record<SupportedCountry, () => string> = { Netherlands: () => { // 010 99xxxxxx (Rotterdam, test range) const random = Math.floor(100000 + Math.random() * 900000); return `010 99${random.toString().padStart(6, '0')}`; }, Germany: () => { // 030 99xxxxx (Berlin, test range) const random = Math.floor(10000 + Math.random() * 90000); return `030 99${random.toString().padStart(5, '0')}`; }, Belgium: () => { // 02 99xxxxxx (Brussels, test range) const random = Math.floor(100000 + Math.random() * 900000); return `02 99${random.toString().padStart(6, '0')}`; }, France: () => { // 01 99xxxxxx (Paris, test range) const random = Math.floor(100000 + Math.random() * 900000); return `01 99${random.toString().padStart(6, '0')}`; }, UnitedKingdom: () => { // 020 3999xxxx (London, test range) const random = Math.floor(1000 + Math.random() * 9000); return `020 3999${random.toString().padStart(4, '0')}`; }, Spain: () => { // 91 99xxxxx (Madrid, test range) const random = Math.floor(10000 + Math.random() * 90000); return `91 99${random.toString().padStart(5, '0')}`; }, Italy: () => { // 06 99xxxxxx (Rome, test range) const random = Math.floor(100000 + Math.random() * 900000); return `06 99${random.toString().padStart(6, '0')}`; }, Austria: () => { // 01 99xxxxxx (Vienna, test range) const random = Math.floor(100000 + Math.random() * 900000); return `01 99${random.toString().padStart(6, '0')}`; }, Switzerland: () => { // 044 99xxxxxx (Zurich, test range) const random = Math.floor(100000 + Math.random() * 900000); return `044 99${random.toString().padStart(6, '0')}`; }, Sweden: () => { // 08 99xxxxxx (Stockholm, test range) const random = Math.floor(100000 + Math.random() * 900000); return `08 99${random.toString().padStart(6, '0')}`; }, Norway: () => { // 21 99xxxxxx (Oslo, test range) const random = Math.floor(1000000 + Math.random() * 9000000); return `21 99${random.toString().padStart(6, '0')}`; }, Denmark: () => { // 33 99xxxx (Copenhagen, test range) const random = Math.floor(1000 + Math.random() * 9000); return `33 99${random.toString().padStart(4, '0')}`; }, Finland: () => { // 09 99xxxxxx (Helsinki, test range) const random = Math.floor(100000 + Math.random() * 900000); return `09 99${random.toString().padStart(6, '0')}`; }, Portugal: () => { // 21 99xxxxxx (Lisbon, test range) const random = Math.floor(100000 + Math.random() * 900000); return `21 99${random.toString().padStart(6, '0')}`; }, Ireland: () => { // 01 99xxxxxx (Dublin, test range) const random = Math.floor(100000 + Math.random() * 900000); return `01 99${random.toString().padStart(6, '0')}`; }, Turkey: () => { // 212 99xxxxxx (Istanbul, test range) const random = Math.floor(100000 + Math.random() * 900000); return `212 99${random.toString().padStart(6, '0')}`; }, Morocco: () => { // 0522 99xxxx (Casablanca, test range) const random = Math.floor(1000 + Math.random() * 9000); return `0522 99${random.toString().padStart(4, '0')}`; }, }; export const landlineNumberGenerators = { generateTestLandlineNumber, };