本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス

/it

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

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

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

エクスポート

名前種類概要
compareItalianAddresses関数Compares two addresses in Italy field by field: the street, the civic number, the staircase, the flat, the place 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.
findItalianProvince関数Finds a province of Italy by its sigla (RM, IT-RM) or its name in English, ignoring accents and letter case.
formatPosteItaliane関数Writes an address in Italy as Poste Italiane asks: who it is care of (c/o), the street and its civic number, with the staircase, the floor and the flat after it, or the Casella Postale, then the postcode, the place and the province's sigla, each on its own line.
FormattedAddress型A formatted address: its lines, and the same on one line.
getProvinceFromItalianPostcode関数The province a postcode is in, by its sigla (RM): the one most of GeoNames' places for the postcode are in.
isKnownItalianPostcode関数Whether GeoNames' list for Italy has a postcode (4,736 of them).
isValidItalianPostcode関数Whether a postcode follows Poste Italiane's shape: five digits.
IT_PROVINCES定数The provinces, metropolitan cities and other second-level divisions of Italy.
italy定数Italy's module, for parseLocation and validateAddress: pass it in countries, and an address that ends with Italy, Italia or IT, or has an Italian street's type and a postcode of five digits and a place on its last line, is read as Italian; country: "IT" reads any address as one.
looksItalian関数Whether an address is surely Italian, with no hint: it ends with Italy, Italia or IT, or its last line is a postcode of five digits and a place while a part of the address begins with an Italian street's type (Via, Viale, Corso, Piazza, Largo) or is a Casella Postale, and no state's code stands before the postcode.
ParsedAddress型What parseLocation returns: every part it found, each absent when the address has none.
parseItalianAddress関数Parses an address in Italy into the parts Poste Italiane lays out: who it is care of (careOf), a building (building: Palazzo Rossi), the street as written with its type (street: Via del Corso, V.le Monza), its civic number in number (12, 12-14, or SNC for senza numero civico) with its letter or sub-number in numberExtension (the A of 12/A, bis), the staircase (staircase), the floor (floorType Piano and floor), the flat (secUnitType Interno and secUnitNum), a Casella Postale, the frazione in locality, the place in city, the postcode (CAP) in zip and the province's sigla in state (RM), as written or from the postcode.
parseItalianPostcode関数Takes a postcode apart: the province 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).
PosteItalianeFormattingOptions型Options for formatPosteItaliane.
validateItalianAddress関数Checks an address in Italy: the postcode is five digits and GeoNames' list has it, the province written agrees with the postcode's, and the place and the civic 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 のソースから作成しました。

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