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

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

9.3 kB minified and gzipped, with everything it imports (measured with esbuild)

Exports

NameKindWhat it is
compareFrenchAddressesfunctionCompares two addresses in France field by field: the delivery point, the building, the number and its extension, the type and name of the street, the lieu-dit, the box, the commune and the postcode.
CountryComparisontypeWhat a country module's comparer returns: whether the two addresses are the same delivery point, and every field that differs once both are in the same form (letter case, punctuation, a street type written out or abbreviated).
CountryDifferencetypeOne way two addresses differ, as a country module's comparer reports it: the field, and its value in each address after both were put in the same form.
CountryModuletypeA country's address module: its codes, how to tell its addresses apart, and its parser, validator, formatter and comparer.
CountryValidationtypeWhat a country module's validator returns: the errors and the warnings it found.
findFrenchDepartmentfunctionFinds a department of France by its code (75, 2A, 971) or its name (Paris, Haute-Corse), without regard to letter case or accents.
formatLaPostefunctionWrites 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.
FormattedAddresstypeA formatted address: its lines, and the same on one line.
FR_BUILDING_WORDSconstantThe words that open the line naming a building, a residence or a zone (La Poste's third line), which the parser keeps whole as building (Résidence Les Lilas, Bâtiment A, Zone industrielle Nord, ZAC des Prés), with their abbreviations.
FR_COLLECTIVITIESconstantThe overseas collectivities that have postcodes in La Poste's base: each with its code, its ISO 3166-1 country code and its name.
FR_DEPARTMENTSconstantThe 101 departments of France, in order of their codes, each with its code (75, 2A, 971), its name and its region's.
FR_NUMBER_EXTENSIONSconstantThe words that may follow the number as its indice de répétition: bis, ter, quater and the rest of the Latin series.
FR_STREET_TYPESconstantThe types of voie the parser takes off the front of a street's name and reports, in full, as type (rue de la Paix is street de la Paix, type Rue), with the abbreviations it reads for each.
FR_UNIT_TYPESconstantThe types of the part of a building that an address names below the number: an apartment or a door, which the parser reports as secUnitType and secUnitNum, with the abbreviations it reads for each.
franceconstantFrance's module, for parseLocation and validateAddress: pass it in countries, and an address that ends with France (or Monaco or an overseas territory), holds CEDEX, or has a French type of voie and a postcode first on its last line is read as French; country: "FR" reads any address as one, and so does the code of an overseas department or collectivity.
FrenchAddressFieldstypeThe fields an address in France fills beside the shared ones.
FrenchCollectivitytypeAn overseas collectivity of France in the tables: its code (987), the ISO 3166-1 country code an address in it reads as (PF) and its name.
FrenchDepartmenttypeA department of France in the tables: its code (75, 2A, 971), its name and its region's, from INSEE's Code officiel géographique.
FrenchPostalCountrytypeThe country an address in La Poste's base belongs to: FR for France (the metropolis and the overseas departments), MC for Monaco, and the ISO 3166-1 code of an overseas collectivity (PM, BL, MF, WF, PF, NC), which is French but has a country code of its own and is listed apart by the Universal Postal Union.
FrenchPostcodetypeA postcode taken apart: the code of the department or territory its number belongs to, the country it delivers to, and whether La Poste's base has it.
getDepartmentFromFrenchPostcodefunctionThe department a postcode's number belongs to, by its code: 75 for 75008, 2B for 20200, 971 for 97100.
isKnownFrenchPostcodefunctionWhether La Poste's base officielle des codes postaux lists a postcode: France, the overseas departments and collectivities and Monaco.
isValidFrenchPostcodefunctionWhether a postcode follows La Poste's shape: five digits.
LaPosteFormattingOptionstypeOptions for formatLaPoste.
looksFrenchfunctionWhether an address is surely French, with no hint: it ends with France, an overseas department, Monaco or one of the collectivities, or holds CEDEX beside a postcode, or its last line begins with a postcode whose number names a department, a collectivity or Monaco, followed by a commune (75008 Paris), while the address has a French type of voie (rue, avenue, chemin) at the start of a street, a BP, a TSA or a lieu-dit.
ParsedAddresstypeWhat parseLocation returns: every part it found, each absent when the address has none.
parseFrenchAddressfunctionParses 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.
parseFrenchPostcodefunctionTakes a postcode apart: the code of the department or territory its number belongs to, and the country it delivers to (FR for France and its overseas departments, MC for Monaco, PF, NC and the other collectivities' own codes), and whether La Poste's base lists it.
ParseOptionstypeOptions for every parser: the country, strict postal codes, snake_case keys and the rest.
validateFrenchAddressfunctionChecks an address in France against La Poste's postcode shape and the tables: the postcode is five digits, its number names a department, a collectivity or Monaco, and La Poste's base officielle lists it.
ValidationErrortypeOne finding of a validator: the field it is about, its code, a message, and how serious it is.
ValidationOptionstypeOptions for the validators: which parts an address must have, which kinds are allowed, and whether a postal code that does not match its region is an error.

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