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

/es

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

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

Exports

NameKindWhat it is
compareSpanishAddressesfunctionCompares two addresses in Spain field by field: the street, the number, the floor and the door, the place and the postcode.
CorreosFormattingOptionstypeOptions for formatCorreos.
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.
ES_PROVINCESconstantThe provinces of Spain, with the two cities that are no province's.
findSpanishProvincefunctionFinds a province of Spain by its code (M, ES-M) or its name in English, ignoring accents and letter case.
formatCorreosfunctionWrites 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.
FormattedAddresstypeA formatted address: its lines, and the same on one line.
getProvinceFromSpanishPostcodefunctionThe province a postcode is in, as its ISO 3166-2 code without ES-: the province its first two digits name.
isKnownSpanishPostcodefunctionWhether GeoNames' list for Spain has a postcode (11,150 of them).
isValidSpanishPostcodefunctionWhether a postcode follows Correos' shape: five digits, the first two a province's number (01 to 52).
looksSpanishfunctionWhether 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.
ParsedAddresstypeWhat parseLocation returns: every part it found, each absent when the address has none.
ParseOptionstypeOptions for every parser: the country, strict postal codes, snake_case keys and the rest.
parseSpanishAddressfunctionParses 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.
parseSpanishPostcodefunctionTakes a postcode apart: the province it is in, and whether GeoNames' list has it.
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).
spainconstantSpain'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.
validateSpanishAddressfunctionChecks 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.
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.