本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス

/nz

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

最小化と gzip 圧縮をしたサイズは 6.3 kB(読み込むものをすべて含み、esbuild で計測)

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

エクスポート

名前種類概要
compareNewZealandAddresses関数Compares two addresses in New Zealand field by field: the unit, the street, its number, the city and the postcode.
CountryComparison型What 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).
CountryDifference型One 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.
CountryModule型A country's address module: its codes, how to tell its addresses apart, and its parser, validator, formatter and comparer.
CountryValidation型What a country module's validator returns: the errors and the warnings it found.
findNewZealandRegion関数Finds a region of New Zealand by its code (AUK, NZ-AUK) or its name in English, ignoring macrons, hyphens and letter case.
formatNZPost関数Writes an address in New Zealand as NZ Post asks: who it is care of, the unit and the level, the street with its number (or the PO Box, the bag or the rural delivery), the suburb, then the city and the postcode, each on its own line.
FormattedAddress型A formatted address: its lines, and the same on one line.
getRegionFromNewZealandPostcode関数The region a postcode is in, by its ISO 3166-2 code without NZ- (AUK for Auckland): the one most of GeoNames' places for the postcode are in.
isKnownNewZealandPostcode関数Whether GeoNames' list for New Zealand has a postcode (1,737 of them).
isValidNewZealandPostcode関数Whether a postcode follows NZ Post's shape: four digits.
looksNewZealand関数Whether an address is surely from New Zealand, with no hint: it ends with New Zealand, Aotearoa or NZ, or it ends with a place and a postcode that GeoNames' list for New Zealand has and has a Private Bag, a rural delivery (RD 2) or Aotearoa in it.
newZealand定数New Zealand's module, for parseLocation and validateAddress: pass it in countries, and an address that ends with New Zealand, Aotearoa or NZ is read as from New Zealand; country: "NZ" reads any address as one.
NZ_REGIONS定数The regions of New Zealand.
NZPostFormattingOptions型Options for formatNZPost.
ParsedAddress型What parseLocation returns: every part it found, each absent when the address has none.
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.
parseNewZealandPostcode関数Takes a postcode apart: the region it is in, and whether GeoNames' list has it.
ParseOptions型Options for every parser: the country, strict postal codes, snake_case keys and the rest.
PostcodeLookup型A postcode taken apart: its canonical form, the region it is in (when the country's table has regions), and whether the country's list has it.
PostcodeRegion型A region a postcode can be in, as a country's table holds it: its code, its ISO 3166-2 code, and its name in English and in Japanese (from kuni, which takes them from Unicode CLDR and Wikidata).
validateNewZealandAddress関数Checks an address in New Zealand: the postcode is four digits and GeoNames' list has it, and the city and the street's number are given.
ValidationError型One finding of a validator: the field it is about, its code, a message, and how serious it is.
ValidationOptions型Options 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.

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

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