本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス · 日本の住所

JapaneseAddressFields型

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

The fields a Japanese address fills on top of the shared ones. Every value is normalised: full-width and kanji numerals become ASCII digits, and the block is split into chome, ban and go whichever way it was written.

インポート

import type { JapaneseAddressFields } from "@johnmorrisdotca/address-plus/jp";

ほかのエクスポート元: @johnmorrisdotca/address-plus

定義

interface JapaneseAddressFields {
    postalCode?: string;
    prefecture?: string;
    prefectureCode?: string;
    prefectureRomaji?: string;
    municipality?: string;
    municipalityCode?: string;
    municipalityRomaji?: string;
    streetDirections?: string;
    town?: string;
    chome?: string;
    ban?: string;
    go?: string;
    block?: string;
    building?: string;
    floor?: string;
    room?: string;
}

メンバー

名前型説明
postalCode (省略可)string | undefined
prefecture (省略可)string | undefined
prefectureCode (省略可)string | undefined
prefectureRomaji (省略可)string | undefined
municipality (省略可)string | undefined
municipalityCode (省略可)string | undefined
municipalityRomaji (省略可)string | undefined
streetDirections (省略可)string | undefined
town (省略可)string | undefined
chome (省略可)string | undefined
ban (省略可)string | undefined
go (省略可)string | undefined
block (省略可)string | undefined
building (省略可)string | undefined
floor (省略可)string | undefined
room (省略可)string | undefined

例

import { parseLocation } from "@johnmorrisdotca/address-plus";
import type { JapaneseAddressFields } from "@johnmorrisdotca/address-plus/jp";

console.log(parseLocation("〒100-0005 東京都千代田区丸の内1丁目2番3号")?.municipalityCode);
// → "13101"
13101

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

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

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