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

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

7.2 kB minified and gzipped, with everything it imports (measured with esbuild)

Exports

NameKindWhat it is
AU_CROSS_BORDER_POSTCODESconstantThe postcodes whose area lies in more than one state or territory, each with the states it lies in, the one with most of it first.
AU_EXTERNAL_TERRITORY_POSTCODESconstantThe postcodes the Australian Bureau of Statistics places, wholly or partly, in the Other Territories: Jervis Bay, Norfolk Island, Christmas Island and the Cocos (Keeling) Islands.
AU_POSTCODE_RANGESconstantThe blocks of postcodes Australia Post allocates to each state and territory.
AU_STATESconstantThe six states and two territories of Australia, in order of their codes, each with Australia Post's code, the ISO 3166-2 code and its name in English and in Japanese.
AU_STREET_TYPESconstantAustralia's street types: each AS4590 abbreviation, in proper case as the parser reports it, with the word it stands for.
australiaconstantAustralia's module, for parseLocation and validateAddress: pass it in countries, and an address that ends with a state and its postcode (or Australia) is read as Australian; country: "AU" reads any address as one.
AustralianAddressFieldstypeThe fields an Australian address fills beside the shared ones.
AustralianPostcodeRangetypeOne block of postcodes Australia Post allocates to a state or territory: every postcode from from to to, inclusive, written as four digits.
AustralianStatetypeAn Australian state or territory in the tables: Australia Post's code, the ISO 3166-2 code, and its name in English and in Japanese (from kuni, which takes them from Unicode CLDR and Wikidata).
AustralianStateCodetypeThe code of an Australian state or territory, as Australia Post writes it on the last line of an address.
AustraliaPostFormattingOptionstypeOptions for formatAustraliaPost.
compareAustralianAddressesfunctionCompares two Australian addresses field by field: the unit, level, lot, number, street, suburb, state and postcode.
CountryComparisontypeWhat a country module's comparer returns: whether the two addresses are the same delivery point, and every field that differs once both are in the same form (letter case, punctuation, a street type written out or abbreviated).
CountryDifferencetypeOne way two addresses differ, as a country module's comparer reports it: the field, and its value in each address after both were put in the same form.
CountryModuletypeA country's address module: its codes, how to tell its addresses apart, and its parser, validator, formatter and comparer.
CountryValidationtypeWhat a country module's validator returns: the errors and the warnings it found.
expandAustralianStreetTypefunctionThe word an AS4590 street type stands for: Pde is Parade.
findAustralianStatefunctionFinds an Australian state or territory by its code (VIC, AU-VIC, Vic.) or its name in English or Japanese (Victoria, ビクトリア州), in any letter case.
formatAustraliaPostfunctionWrites an Australian address as Australia Post asks: the building's name, then the delivery line (unit and level before the number, the street type abbreviated), then the suburb, state and postcode, both in capitals with no punctuation.
FormattedAddresstypeA formatted address: its lines, and the same on one line.
getPostcodeRangesForAustralianStatefunctionThe blocks of postcodes Australia Post allocates to a state or territory.
getStateFromAustralianPostcodefunctionThe state or territory whose block of postcodes a postcode is in.
getStatesForAustralianPostcodefunctionEvery state or territory a postcode serves: its block's state, and for a postcode that crosses a border, the states across it too, the one with most of the postcode's area first.
looksAustralianfunctionWhether an address is surely Australian, with no hint: it ends with Australia, or with a state and an Australian postcode (NSW 2150, Victoria 3000, VIC 2000, whose postcode is Sydney's).
parseAustralianAddressfunctionParses an Australian address into its parts, as Australia Post lays one out: the delivery line, then the suburb or town, the state and the postcode.
ParsedAddresstypeWhat parseLocation returns: every part it found, each absent when the address has none.
ParseOptionstypeOptions for every parser: the country, strict postal codes, snake_case keys and the rest.
validateAustralianAddressfunctionChecks an Australian address against Australia Post's blocks of postcodes: the postcode is four digits, some state's block holds it, and it is the state named, or one it serves across a border (from the ABS's Postal Areas).
ValidationErrortypeOne finding of a validator: the field it is about, its code, a message, and how serious it is.
ValidationOptionstypeOptions for the validators: which parts an address must have, which kinds are allowed, and whether a postal code that does not match its region is an error.

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