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 · Japanese addresses

JapaneseFormattingOptionstype

Options for formatJapanese.

Import it

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

Also exported from: @johnmorrisdotca/address-plus

Definition

interface JapaneseFormattingOptions {
    blockStyle?: "hyphen" | "markers";
    includePostalCode?: boolean;
    multiline?: boolean;
}

Members

NameTypeDescription
blockStyle (optional)"hyphen" | "markers" | undefined
includePostalCode (optional)boolean | undefined
multiline (optional)boolean | undefined

Examples

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

const parsedAddress1=parseLocation("〒100-0005 東京都千代田区丸の内1-2-3");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatJapanese(parsedAddress1, { blockStyle: "markers", includePostalCode: false }));
// → "東京都千代田区丸の内1丁目2番3号"
東京都千代田区丸の内1丁目2番3号

What it prints (run when this page was built)

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