本文へ移動

address-plusアドレスプラス

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

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

目次

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

validateJapaneseAddress関数

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

Checks a parsed Japanese address against the tables: the postal code's shape, whether any code begins with its first three digits, whether it delivers to the prefecture named, and whether the municipality is a real one in that prefecture.

インポート

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

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

定義

function validateJapaneseAddress(address: ParsedAddress, options?: ValidationOptions): JapaneseValidation

引数

名前型説明
addressParsedAddress

The address, as parseLocation returns it for a Japanese address.

options (省略可)ValidationOptions

strictPostalValidation makes the postal findings errors rather than warnings; the municipality findings stay warnings.

戻り値

JapaneseValidation

The errors and the warnings, each with its field, code and message.

例

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

const parsedAddress1=parseLocation("〒530-0001 東京都千代田区丸の内1-2-3");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(validateJapaneseAddress(parsedAddress1).warnings.map((one) => one.code));
// → ["POSTAL_REGION_MISMATCH"]
[ 'POSTAL_REGION_MISMATCH' ]

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

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

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