Skip to content

KushalP/uk_postcode

Folders and files

NameName
Last commit message
Last commit date
Apr 29, 2021
Mar 19, 2015
Jun 19, 2018
Mar 20, 2015
Mar 19, 2015
Jul 23, 2019
Mar 19, 2015
Mar 19, 2015
Jul 23, 2019
Apr 19, 2021

Repository files navigation

UK Postcode

Build Status Hex Version Inline docs

UK postcode parsing and validation for Elixir. Based on the excellent Ruby library of the same name by @threedaymonk.

Usage

Validate full postcodes or parts of a postcode.

UKPostcode.valid? "W1A 1AA" #=> true
UKPostcode.full? "W1A 1AA"  #=> true
UKPostcode.outcode? "W1A"   #=> true

Extract parts of a full postcode.

UKPostcode.outcode "W1A 1AA" #=> "W1A"
UKPostcode.incode "W1A 1AA"  #=> "1AA"

Normalise badly formatted postcodes.

UKPostcode.normalise "w1a1aa"  #=> "W1A 1AA"