Skip to the content

address-plusアドレスプラス

Parse, validate, format and compare addresses locally, add country modules and mount an optional native form field.

address-plus extends the parse-address style with typed results, validation, formatting and country modules. About the name

Contents

Reference

/it

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

8.8 kB minified and gzipped, with everything it imports (measured with esbuild)

Exports

NameKindWhat it is
compareItalianAddressesfunctionCompares two addresses in Italy field by field: the street, the civic number, the staircase, the flat, the place and the postcode.
CountryComparisontypeWhat 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).
CountryDifferencetypeOne 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.
CountryModuletypeA country's address module: its codes, how to tell its addresses apart, and its parser, validator, formatter and comparer.
CountryValidationtypeWhat a country module's validator returns: the errors and the warnings it found.
findItalianProvincefunctionFinds a province of Italy by its sigla (RM, IT-RM) or its name in English, ignoring accents and letter case.
formatPosteItalianefunctionWrites 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.
FormattedAddresstypeA formatted address: its lines, and the same on one line.
getProvinceFromItalianPostcodefunctionThe province a postcode is in, by its sigla (RM): the one most of GeoNames' places for the postcode are in.
isKnownItalianPostcodefunctionWhether GeoNames' list for Italy has a postcode (4,736 of them).
isValidItalianPostcodefunctionWhether a postcode follows Poste Italiane's shape: five digits.
IT_PROVINCESconstantThe provinces, metropolitan cities and other second-level divisions of Italy.
italyconstantItaly'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.
looksItalianfunctionWhether 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.
ParsedAddresstypeWhat parseLocation returns: every part it found, each absent when the address has none.
parseItalianAddressfunctionParses 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.
parseItalianPostcodefunctionTakes a postcode apart: the province it is in, and whether GeoNames' list has it.
ParseOptionstypeOptions for every parser: the country, strict postal codes, snake_case keys and the rest.
PostcodeLookuptypeA 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.
PostcodeRegiontypeA 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).
PosteItalianeFormattingOptionstypeOptions for formatPosteItaliane.
validateItalianAddressfunctionChecks 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.
ValidationErrortypeOne finding of a validator: the field it is about, its code, a message, and how serious it is.
ValidationOptionstypeOptions 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.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/address-plus 1.10.2.