本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス

/es

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

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

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

エクスポート

名前種類概要
compareSpanishAddresses関数Compares two addresses in Spain field by field: the street, the number, the floor and the door, the place and the postcode.
CorreosFormattingOptions型Options for formatCorreos.
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.
ES_PROVINCES定数The provinces of Spain, with the two cities that are no province's.
findSpanishProvince関数Finds a province of Spain by its code (M, ES-M) or its name in English, ignoring accents and letter case.
formatCorreos関数Writes an address in Spain as Correos asks: who it is care of (A/A), the street with its number and the floor and the door (Calle de Alcalá, 42, 3º B), or the Apartado de Correos, then the postcode and the place, each on its own line.
FormattedAddress型A formatted address: its lines, and the same on one line.
getProvinceFromSpanishPostcode関数The province a postcode is in, as its ISO 3166-2 code without ES-: the province its first two digits name.
isKnownSpanishPostcode関数Whether GeoNames' list for Spain has a postcode (11,150 of them).
isValidSpanishPostcode関数Whether a postcode follows Correos' shape: five digits, the first two a province's number (01 to 52).
looksSpanish関数Whether an address is surely Spanish, with no hint: it ends with Spain, España or ES, or its last line is a postcode of five digits (the first two 01 to 52) and a place while a part of the address begins with a Spanish street's type (Calle, C/, Avenida, Paseo, Plaza) or is an Apartado de Correos, and no state's code stands before the postcode.
ParsedAddress型What parseLocation returns: every part it found, each absent when the address has none.
ParseOptions型Options for every parser: the country, strict postal codes, snake_case keys and the rest.
parseSpanishAddress関数Parses an address in Spain into the parts Correos lays out: who it is care of (careOf), the street as written with its type (street: Calle de Alcalá, C/ Mayor), its number in number (42, 12-14, S/N), the floor and the door (floorType Piso and floor, secUnitType Puerta and secUnitNum: 3º B), the staircase and the entrance, an Apartado de Correos, the place in city, the province in county when it is written in brackets, the postcode in zip and the province's code in state (M for Madrid), from the postcode.
parseSpanishPostcode関数Takes a postcode apart: the province it is in, and whether GeoNames' list has it.
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).
spain定数Spain's module, for parseLocation and validateAddress: pass it in countries, and an address that ends with Spain, España or ES, or has a Spanish street's type and a postcode of five digits and a place on its last line, is read as Spanish; country: "ES" reads any address as one.
validateSpanishAddress関数Checks an address in Spain: the postcode is five digits with a province's number first and GeoNames' list has it, the province written agrees with the postcode's, and the place 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 のソースから作成しました。

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