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

AustraliaPostFormattingOptionstype

Options for formatAustraliaPost.

Import it

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

Definition

interface AustraliaPostFormattingOptions {
    unitStyle?: "words" | "slash";
    wideSpacing?: boolean;
    includeCountry?: boolean;
}

Members

NameTypeDescription
unitStyle (optional)"words" | "slash" | undefined
wideSpacing (optional)boolean | undefined
includeCountry (optional)boolean | undefined

Examples

import { formatAustraliaPost, parseAustralianAddress } from "@johnmorrisdotca/address-plus/au";
import type { AustraliaPostFormattingOptions } from "@johnmorrisdotca/address-plus/au";

const parsedAddress1=parseAustralianAddress("Unit 3, 12 Smith St, Parramatta NSW 2150");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatAustraliaPost(parsedAddress1, { unitStyle: "slash" }).lines);
// → ["3/12 SMITH ST","PARRAMATTA NSW 2150"]
[ '3/12 SMITH ST', 'PARRAMATTA NSW 2150' ]

What it prints (run when this page was built)

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