本文へ移動

address-plusアドレスプラス

住所を端末の中で解析・確認・整形・比較し、国のモジュールや任意のフォームの入力欄を使えます。

address-plusは、parse-addressの使い方を広げ、型付きの結果、確認、書式、国のモジュールを加えます。 名前について(英語)

目次

リファレンス · /nz

parseNewZealandAddress関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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 { parseNewZealandAddress } from "@johnmorrisdotca/address-plus/nz";

定義

function parseNewZealandAddress(text: string, options?: ParseOptions): ParsedAddress | null

引数

名前型説明
textstring

The address as one string; commas and line breaks both separate its parts.

options (省略可)ParseOptions

useSnakeCase gives snake_case keys; the other options are not used.

戻り値

ParsedAddress | null

The parts found, with country NZ, or null when the text is empty or holds nothing that makes it an address.

例

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'
}

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/address-plus 1.10.2 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。