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

franceconstant

France'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. It reads Monaco (MC) and the collectivities (PM, BL, MF, WF, PF, NC) too, and reports their own codes.

Import it

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

Definition

const france: CountryModule = {
    code: "FR",
    codes: ["FR", "MC", "GP", "MQ", "GF", "RE", "YT", "PM", "BL", "MF", "WF", "PF", "NC"],
    name: "France",
    detect: looksFrench,
    parse: parseFrenchAddress,
    validate: validateFrenchAddress,
    format: (address) => formatLaPoste(address),
    compare: compareFrenchAddresses,
}

Members

NameTypeDescription
codestring
codesreadonly string[]
namestring
detect(address: string): boolean
parse(address: string, options?: ParseOptions): ParsedAddress | null
validate(address: ParsedAddress, options?: ValidationOptions): CountryValidation
format(address: ParsedAddress): FormattedAddress
compare(first: ParsedAddress, second: ParsedAddress): CountryComparison

Examples

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

console.log(parseLocation("12 bis rue de la Paix, 75002 Paris, France", { countries: [france] })?.numberExtension);
// → "bis"
bis

What it prints (run when this page was built)

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