本文へ移動

address-plusアドレスプラス

住所を端末の中で解析・確認・整形・比較し、国のモジュールや任意のフォームの入力欄を使えます。

address-plusは、parse-addressの使い方を広げ、型付きの結果、確認、書式、国のモジュールを加えます。 名前について(英語)

目次

リファレンス · /es

parseSpanishAddress関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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 { parseSpanishAddress } from "@johnmorrisdotca/address-plus/es";

定義

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

引数

名前型説明
textstring

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

options (省略可)ParseOptions

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

戻り値

ParsedAddress | null

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

例

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'
}

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/address-plus 1.10.2 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。