本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス · 解析・書式・共通の型

validateAddress関数

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

Checks an address: whether it has what an address needs, whether its ZIP or postal code is well formed and belongs to the state, province or prefecture named, and how sure the parser is. With country modules in options.countries, an Australian or British address is checked by its module's validator.

インポート

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

定義

function validateAddress(addressString: string, options?: ValidationOptions): AddressValidationResult

引数

名前型説明
addressStringstring

The address as one string.

options (省略可)ValidationOptions

What to require and how strict to be (see ValidationOptions).

戻り値

AddressValidationResult

Whether it is valid, the confidence and completeness from 0 to 1, every error and warning with its code, suggestions, and the parsed address (null when it could not be parsed).

例

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

console.log(validateAddress("123 Main St, Seattle, NY 98101").warnings[0].code);
// → "POSTAL_REGION_MISMATCH"
POSTAL_REGION_MISMATCH

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

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

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