Skip to the content

address-plusアドレスプラス

Parse, validate, format and compare addresses locally, add country modules and mount an optional native form field.

address-plus extends the parse-address style with typed results, validation, formatting and country modules. About the name

Contents

Reference · French country module

formatLaPostefunction

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 it

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

Definition

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

Parameters

NameTypeDescription
addressParsedAddress

The address as parseFrenchAddress returns it.

options (optional)LaPosteFormattingOptions

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

Returns

FormattedAddress

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

Examples

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'
]

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/address-plus 1.7.0.