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
引数
| 名前 | 型 | 説明 |
|---|---|---|
addressString | string | The address as one string. |
options (省略可) | ValidationOptions | What to require and how strict to be (see |
戻り値
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出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。