UKPostcode
UK postcode parsing, validation and normalisation module.
Summary↑
full?(postcode) | Returns true or false depending on if the value is a full valid postcode |
incode(postcode) | Extracts the right-hand part of the postcode |
normalise(postcode) | Returns the canonical string representation of the postcode |
outcode(postcode) | Extracts the left-hand part of the postcode |
outcode?(postcode) | Returns true or false depending on if the value is a valid left-hand value of a valid postcode |
valid?(postcode) | Returns true or false depending on if the value is a valid postcode. This includes both full postcodes and outcode postcodes |
Functions
Returns true or false depending on if the value is a full valid postcode.
postcode - String postcode
Examples
iex> UKPostcode.full? "W1A 1AA"
true
Extracts the right-hand part of the postcode.
postcode - String postcode
Examples
iex> UKPostcode.incode "W1A 1AA"
{:ok, "1AA"}
Returns the canonical string representation of the postcode.
postcode - String postcode
Examples
iex> UKPostcode.normalise "w1a1aa"
"W1A 1AA"
Extracts the left-hand part of the postcode.
postcode - String postcode
Examples
iex> UKPostcode.outcode "W1A 1AA"
{:ok, "W1A"}
Returns true or false depending on if the value is a valid left-hand value of a valid postcode.
postcode - String postcode
Examples
iex> UKPostcode.outcode? "W1A"
true
Returns true or false depending on if the value is a valid postcode. This includes both full postcodes and outcode postcodes.
postcode - String postcode
Examples
iex> UKPostcode.valid? "W1A 1AA"
true
iex> UKPostcode.valid? "W1A"
true