parseNewZealandAddressfunction
Parses an address in New Zealand into the parts NZ Post lays out: who it is care of (careOf), the unit (secUnitType
and secUnitNum, from Unit 3 or the 3 of 3/45), the level (floorType and floor), the street's number (number:
45, 12A, 12-14) and its name as written (street: Dominion Road), the suburb in locality, the city in city,
a PO Box, a Private Bag or a rural delivery (secUnitType RD and secUnitNum), the postcode in zip and the
region's code in state (AUK), from the postcode. The city stands before the postcode.
Import it
import { parseNewZealandAddress } from "@johnmorrisdotca/address-plus/nz";
Definition
function parseNewZealandAddress(text: string, options?: ParseOptions): ParsedAddress | null
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The address as one string; commas and line breaks both separate its parts. |
options (optional) | ParseOptions |
|
Returns
ParsedAddress | null
The parts found, with country NZ, or null when the text is empty or holds nothing that makes it an
address.
Examples
import { parseNewZealandAddress } from "@johnmorrisdotca/address-plus/nz";
console.log(parseNewZealandAddress("3/45 Dominion Road, Mount Eden, Auckland 1024"));
// → {"secUnitType":"Unit","secUnitNum":"3","number":"45","street":"Dominion Road","locality":"Mount Eden","city":"Auckland","state":"AUK","zip":"1024","zipValid":true,"country":"NZ"}{
secUnitType: 'Unit',
secUnitNum: '3',
number: '45',
street: 'Dominion Road',
locality: 'Mount Eden',
city: 'Auckland',
state: 'AUK',
zip: '1024',
zipValid: true,
country: 'NZ'
}What it prints (run when this page was built)