RandomAPI / Randomuser.me-old-source

[Deprecated] PHP source for Random User Generator - Please take a look at the new Node version
https://randomuser.me
137 stars 48 forks source link

GB Postcode & Phone Number Formats #16

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi

This is an awesome API - just a couple of improvements for GB based users would help as follows...

GB Postcode formats are alphanumeric and between six and eight characters long. They are divided into two parts separated by a single space. Examples of postcodes include "SW1W 0NY", "PO16 7GZ", "GU16 7HF", or "L1 8JQ".

As for phone numbers well... formatting them can be complex. You can read much more detail here: http://www.area-codes.org.uk/formatting.php

The basic list of geographic patterns below show the various valid formats in the UK: 01### ##### 01### ###### 011# ### #### 01#1 ### #### 013873 ##### 015242 ##### 015394 ##### 015395 ##### 015396 ##### 016973 ##### 016974 ##### 016977 #### 016977 ##### 017683 ##### 017684 ##### 017687 ##### 019467 ##### 02# #### ####

Non geographic numbers: 03## ### #### 05### ###### 0500 ###### 07### ###### Note: Mobile (Cell) numbers always begin "07..." 0800 ###### 08## ### #### 09## ### ####

Hope that helps!

Cheers

keitharm commented 9 years ago

Hi @burgons! Thanks for the info, we'll definitely implement these improvements for the next update.

Just one question though...your "L1 8JQ" example postcode is only 5 characters long? Was there another postcode format other than <4 alphanumeric characters><space><3 alphanumeric characters>?

ghost commented 9 years ago

Glad to help...

All of the previous examples are indeed correct. This might clear it up:

Royal Mail introduced postcodes to the United Kingdom between 1959 and 1974. The format of a UK postcode is always one of the following: LN NLL LLN NLL LNN NLL LLNN NLL LLNL NLL LNL NLL

Where L represents a letter, and N a number. The first letter (or pair of letters) represents the area, the following number the district and so on. Typically a full postcode represents a street, a part of a street or a small village. Each unique code usually limits the area down to up to 80 properties.

The postcode is split into two parts - the part before the space is knows as the outward code [which can be from 2 to 4 characters in length] and is used to route mail to the correct regional sorting office.

The part after the space is known as the inward code [it is always 3 characters in length] and is used to sort the mail into individual delivery rounds from the destination sorting office.

The inward code may only contain letters from the set ABDEFGHJLNPQRSTUWXYZ - not the full alphabet - this is to avoid using letters that when hand-written could be mistaken for other letters or numbers.

keitharm commented 9 years ago

Ah ok, that clears it up :)

Thanks for the info, it'll be in an upcoming update!