validatePostalCode関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Checks the shape of a US ZIP code or a Canadian postal code.
インポート
import { validatePostalCode } from "@johnmorrisdotca/address-plus";
定義
function validatePostalCode(code: string): PostalValidationResult
引数
| 名前 | 型 | 説明 |
|---|---|---|
code | string | The code, with or without the space or the ZIP+4. |
戻り値
PostalValidationResult
Whether it is well formed, its type (zip or postal), and the code written the standard way.
例
import { validatePostalCode } from "@johnmorrisdotca/address-plus";
console.log(validatePostalCode("k1a0b1"));
// → {"isValid":true,"type":"postal","formatted":"K1A 0B1","message":"Valid Canadian postal code format"}{
isValid: true,
type: 'postal',
formatted: 'K1A 0B1',
message: 'Valid Canadian postal code format'
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。