Reference
/es
import { … } from "@johnmorrisdotca/address-plus/es";
10.2 kB minified and gzipped, with everything it imports (measured with esbuild)
Exports
| Name | Kind | What it is |
|---|---|---|
compareSpanishAddresses | function | Compares two addresses in Spain field by field: the street, the number, the floor and the door, the place and the postcode. |
CorreosFormattingOptions | type | Options for formatCorreos. |
CountryComparison | type | 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 | type | 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 | type | A country's address module: its codes, how to tell its addresses apart, and its parser, validator, formatter and comparer. |
CountryValidation | type | What a country module's validator returns: the errors and the warnings it found. |
ES_PROVINCES | constant | The provinces of Spain, with the two cities that are no province's. |
findSpanishProvince | function | Finds a province of Spain by its code (M, ES-M) or its name in English, ignoring accents and letter case. |
formatCorreos | function | 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 | type | A formatted address: its lines, and the same on one line. |
getProvinceFromSpanishPostcode | function | The province a postcode is in, as its ISO 3166-2 code without ES-: the province its first two digits name. |
isKnownSpanishPostcode | function | Whether GeoNames' list for Spain has a postcode (11,150 of them). |
isValidSpanishPostcode | function | Whether a postcode follows Correos' shape: five digits, the first two a province's number (01 to 52). |
looksSpanish | function | 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 | type | What parseLocation returns: every part it found, each absent when the address has none. |
ParseOptions | type | Options for every parser: the country, strict postal codes, snake_case keys and the rest. |
parseSpanishAddress | function | 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 | function | Takes a postcode apart: the province it is in, and whether GeoNames' list has it. |
PostcodeLookup | type | 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 | type | 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 | constant | 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 | function | 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 | type | One finding of a validator: the field it is about, its code, a message, and how serious it is. |
ValidationOptions | type | 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. |