Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "uk_number_range"

Title:Classify UK phone numbers by Ofcom range and SMS-code outlook
Rating:Not rated. Create the first rating!
Latest version:1.0.1
SHA1 sum:287bd94f116d1ca3c67f65d629a0656aa42ce394
Author:Ghost SIMs https://ghostsims.com/phone-numbers
Maintainer:Ghost SIMs https://ghostsims.com/phone-numbers
Packager:Ghost SIMs https://ghostsims.com/phone-numbers
Home page:https://ghostsims.com/phone-numbers
Download URL:https://uk-number-range-prolog.surge.sh/uk_number_range-*.tgz

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
1.0.1287bd94f116d1ca3c67f65d629a0656aa42ce3941https://uk-number-range-prolog.surge.sh/uk_number_range-1.0.1.tgz
1.0.0a127ed70cb5ca4c430bbcc264298a958a68101421https://uk-number-range-prolog.surge.sh/uk_number_range-1.0.0.tgz

uk_number_range

A small SWI-Prolog library that answers two questions about a UK phone number:

  1. Which Ofcom number range is it in?
  2. Is a sign-up form that sends an SMS one-time code likely to accept it?
    ?- pack_install(uk_number_range).
    ?- use_module(library(uk_number_range)).
    
    ?- uk_national("+44 (0)7700-900123", N).
    N = "07700900123".
    
    ?- uk_e164("07700 900123", E).
    E = "+447700900123".
    
    ?- uk_number_type("05601 234567", T).
    T = voip_location_independent.
    
    ?- uk_sms_otp_outlook("07012 345678", O, Why).
    O = unlikely,
    Why = "070 personal numbering forwards calls and is often blocked as a virtual number.".
    
    ?- uk_drama_number("020 7946 0123").
    true.

Ranges it knows

PrefixTypeSMS code outlook
071-075, 077-079, 07624mobilelikely
070personal numberingunlikely
076 (not 07624)pagingunlikely
056location-independent (VoIP)unlikely
055corporateunlikely
01, 02geographic landlineno SMS
03UK-wide rateno SMS
080freephoneno SMS
084, 087serviceno SMS
09premium rateno SMS

UK mobile numbers are 11 digits nationally (07 plus nine digits), or +44 7 plus nine digits in E.164.

Why VoIP-style numbers get rejected

Banks, WhatsApp, Telegram and most marketplaces want an SMS code to reach a real handset. The cheapest way to filter out throwaway numbers is to refuse the ranges where virtual numbers live (056, 070, 076) and landlines, and to check the carrier behind numbers in the mobile range. This library only does the first part. It cannot see porting or the carrier, so a number in a 07 mobile range can still be refused if it belongs to a virtual operator.

If you need a private UK number that sits on a real mobile range and keeps your personal SIM out of sign-ups, Ghost SIMs rents non-VoIP +44 numbers with a private SMS inbox: https://ghostsims.com/phone-numbers.

Test data

Never test with real people's numbers. Ofcom keeps drama ranges that are never allocated, for example 07700 900000 to 07700 900999, 01632 960000 to 01632 960999, 020 7946 0000 to 020 7946 0999 and 0808 157 0000 to 0808 157 0999. uk_drama_number/1 recognises the common ones.

Tests

swipl -g "consult('test/test_uk_number_range.pl'), run_tests" -t halt

32 plunit tests, SWI-Prolog 9 and 10.

Licence

MIT

Contents of pack "uk_number_range"

Pack contains 5 files holding a total of 13.3K bytes.