parseSpanishAddressfunction
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. The number may follow the street after a
comma or not.
Import it
import { parseSpanishAddress } from "@johnmorrisdotca/address-plus/es";
Definition
function parseSpanishAddress(text: string, options?: ParseOptions): ParsedAddress | null
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The address as one string; commas and line breaks both separate its parts. |
options (optional) | ParseOptions |
|
Returns
ParsedAddress | null
The parts found, with country ES, or null when the text is empty or holds nothing that makes it an
address.
Examples
import { parseSpanishAddress } from "@johnmorrisdotca/address-plus/es";
console.log(parseSpanishAddress("Calle de Alcalá, 42, 3º B, 28014 Madrid"));
// → {"secUnitType":"Puerta","secUnitNum":"B","floorType":"Piso","floor":"3","number":"42","street":"Calle de Alcalá","city":"Madrid","state":"M","zip":"28014","zipValid":true,"country":"ES"}{
secUnitType: 'Puerta',
secUnitNum: 'B',
floorType: 'Piso',
floor: '3',
number: '42',
street: 'Calle de Alcalá',
city: 'Madrid',
state: 'M',
zip: '28014',
zipValid: true,
country: 'ES'
}What it prints (run when this page was built)