uk_postcode v1.0.0 UKPostcode View Source

UK postcode parsing, validation and normalisation module.

Link to this section Summary

Functions

Returns true or false depending on if the value is a full valid postcode

Extracts the right-hand part of the postcode

Returns the canonical string representation of the postcode

Extracts the left-hand part of the postcode

Returns true or false depending on if the value is a valid left-hand value of a valid postcode

Returns true or false depending on if the value is a valid postcode. This includes both full postcodes and outcode postcodes

Link to this section 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"
"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"
"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