本文へ移動

address-plusアドレスプラス

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

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

目次

リファレンス · フランスのモジュール

formatLaPoste関数

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

Writes an address in France as La Poste's specification asks (SP 8855): the person it is care of, then the line of the apartment, the floor and the staircase, the line of the entrance and the building, the number and street, the lieu-dit and the box, then the postcode, the commune and its CEDEX, each on its own line, in capitals without accents or punctuation. The arrondissement of Paris, Lyon or Marseille is not written when there is a postcode, which carries it (75008 PARIS, as La Poste's own list has it); without one it is written in two digits (PARIS 08).

インポート

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

定義

function formatLaPoste(address: ParsedAddress, options?: LaPosteFormattingOptions): FormattedAddress

引数

名前型説明
addressParsedAddress

The address as parseFrenchAddress returns it.

options (省略可)LaPosteFormattingOptions

Whether to add the country, and whether to keep accents (see LaPosteFormattingOptions).

戻り値

FormattedAddress

The lines, the same on one line, the delivery line (the number and street) and the last line.

例

import { formatLaPoste, parseFrenchAddress } from "@johnmorrisdotca/address-plus/fr";

const parsedAddress1=parseFrenchAddress("Apt 12, Résidence Les Lilas, 4 bis av. des Écoles, 31000 Toulouse");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatLaPoste(parsedAddress1).lines);
// → ["APPARTEMENT 12","RESIDENCE LES LILAS","4 BIS AVENUE DES ECOLES","31000 TOULOUSE"]
[
  'APPARTEMENT 12',
  'RESIDENCE LES LILAS',
  '4 BIS AVENUE DES ECOLES',
  '31000 TOULOUSE'
]

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

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

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