Skip to the content

address-plusアドレスプラス

Parse, validate, format and compare addresses locally, add country modules and mount an optional native form field.

address-plus extends the parse-address style with typed results, validation, formatting and country modules. About the name

Contents

Reference · Australian country module

getStateFromAustralianPostcodefunction

The state or territory whose block of postcodes a postcode is in. A postcode that also serves a town across a border still gives the state of its block; getStatesForAustralianPostcode gives them all.

Import it

import { getStateFromAustralianPostcode } from "@johnmorrisdotca/address-plus/au";

Definition

function getStateFromAustralianPostcode(postcode: string): AustralianStateCode | undefined

Parameters

NameTypeDescription
postcodestring

Four digits, with or without spaces around them.

Returns

AustralianStateCode | undefined

The state's code, or undefined when the text is not four digits or no block holds it.

Examples

import { getStateFromAustralianPostcode } from "@johnmorrisdotca/address-plus/au";

console.log(getStateFromAustralianPostcode("2620"));
// → "NSW"
NSW

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/address-plus 1.7.0.