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

parseFrenchAddressfunction

Parses an address in France (or Monaco, or an overseas department or collectivity, which are written the same way) into the parts La Poste's norm names: who it is care of (careOf), an apartment or a door (secUnitType, secUnitNum), a floor, a staircase, an entrance, the building or residence (building), the number with its extension (numberExtension: bis, ter, a letter), the type of voie in full in type and its name in street (rue de la Paix is Rue and de la Paix), a lieu-dit, a box (BP 12, CS 30001), the commune in city with its arrondissement and CEDEX, and the postcode in zip with the department's code in state. The postcode may stand anywhere after the street; F-75008 is read as 75008.

Import it

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

Definition

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

Parameters

NameTypeDescription
textstring

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

options (optional)ParseOptions

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

Returns

ParsedAddress | null

The parts found, with country FR (or MC or a collectivity's code), or null when the text is empty or holds nothing that makes it an address.

Examples

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

console.log(parseFrenchAddress("Résidence Les Lilas, 12 bis rue de la Paix, 75002 Paris"));
// → {"building":"Résidence Les Lilas","number":"12","numberExtension":"bis","type":"Rue","street":"de la Paix","city":"Paris","state":"75","zip":"75002","zipValid":true,"country":"FR"}
{
  building: 'Résidence Les Lilas',
  number: '12',
  numberExtension: 'bis',
  type: 'Rue',
  street: 'de la Paix',
  city: 'Paris',
  state: '75',
  zip: '75002',
  zipValid: true,
  country: 'FR'
}

What it prints (run when this page was built)

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