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 · /nz

NZPostFormattingOptionstype

Options for formatNZPost.

Import it

import type { NZPostFormattingOptions } from "@johnmorrisdotca/address-plus/nz";

Definition

interface NZPostFormattingOptions {
    includeCountry?: boolean;
}

Members

NameTypeDescription
includeCountry (optional)boolean | undefined

Examples

import { formatNZPost, parseNewZealandAddress } from "@johnmorrisdotca/address-plus/nz";
import type { NZPostFormattingOptions } from "@johnmorrisdotca/address-plus/nz";

const options: NZPostFormattingOptions = { includeCountry: true };
const parsedAddress1 = parseNewZealandAddress("1 Queen Street, Auckland 1010");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatNZPost(parsedAddress1, options).lines);
// → ["1 Queen Street","Auckland 1010","NEW ZEALAND"]
[ '1 Queen Street', 'Auckland 1010', 'NEW ZEALAND' ]

What it prints (run when this page was built)

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