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

parseItalianAddressfunction

Parses 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.

Import it

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

Definition

function parseItalianAddress(text: string, options?: ParseOptions): ParsedAddress | null

Parameters

NameTypeDescription
textstring

The address as one string; commas and line breaks both separate its parts.

options (optional)ParseOptions

useSnakeCase gives snake_case keys; the other options are not used.

Returns

ParsedAddress | null

The parts found, with country IT, or null when the text is empty or holds nothing that makes it an address.

Examples

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

console.log(parseItalianAddress("Via del Corso, 12/A, 00186 Roma RM"));
// → {"number":"12","numberExtension":"A","street":"Via del Corso","city":"Roma","state":"RM","zip":"00186","zipValid":true,"country":"IT"}
{
  number: '12',
  numberExtension: 'A',
  street: 'Via del Corso',
  city: 'Roma',
  state: 'RM',
  zip: '00186',
  zipValid: true,
  country: 'IT'
}

What it prints (run when this page was built)

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