本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス · /br

parseBrazilianAddress関数

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

Parses an address in Brazil into the parts the Correios lay out: who it is care of (careOf), the street as written with its type (street: Avenida Paulista, R. Augusta), its number (number: 1578, S/N), the complement (secUnitType and secUnitNum: Apto 45, Sala 12; building for a bloco or a torre; floorType Andar and floor), the bairro in locality, the city in city, the CEP in zip (written 01310-200) and the state's code in state (SP), as written or from the CEP. The number follows the street after a comma or not, and the bairro after a hyphen or a comma.

インポート

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

定義

function parseBrazilianAddress(text: string, options?: ParseOptions): ParsedAddress | null

引数

名前型説明
textstring

The address as one string; commas and line breaks both separate its parts.

options (省略可)ParseOptions

useSnakeCase gives snake_case keys; the other options are not used.

戻り値

ParsedAddress | null

The parts found, with country BR, or null when the text is empty or holds nothing that makes it an address.

例

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

console.log(parseBrazilianAddress("Avenida Paulista, 1578 - Bela Vista, São Paulo - SP, 01310-200"));
// → {"number":"1578","street":"Avenida Paulista","locality":"Bela Vista","city":"São Paulo","state":"SP","zip":"01310-200","zipValid":true,"country":"BR"}
{
  number: '1578',
  street: 'Avenida Paulista',
  locality: 'Bela Vista',
  city: 'São Paulo',
  state: 'SP',
  zip: '01310-200',
  zipValid: true,
  country: 'BR'
}

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

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

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