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 · German country module

compareGermanAddressesfunction

Compares two addresses in Germany field by field: who it is care of, the building, the flat and floor, the street, the house number, the place and the postcode. Letter case, ä and ae, ß and ss, a street's suffix written Straße, Strasse or Str., and the postcode's spacing are not differences. The Land and the Ortsteil are left out, since the postcode already says the first.

Import it

import { compareGermanAddresses } from "@johnmorrisdotca/address-plus/de";

Definition

function compareGermanAddresses(first: ParsedAddress, second: ParsedAddress): CountryComparison

Parameters

NameTypeDescription
firstParsedAddress

The first address, as parseGermanAddress returns it.

secondParsedAddress

The second address.

Returns

CountryComparison

Whether they are the same delivery point, and each field that differs.

Examples

import { compareGermanAddresses, parseGermanAddress } from "@johnmorrisdotca/address-plus/de";

const parsedAddress1=parseGermanAddress("Müllerstraße 5, 13353 Berlin");
if (!parsedAddress1) throw new Error("The example address did not parse.");
const parsedAddress2=parseGermanAddress("MUELLERSTR. 5, 13353 BERLIN");
if (!parsedAddress2) throw new Error("The example address did not parse.");
console.log(compareGermanAddresses(parsedAddress1, parsedAddress2).isSame);
// → true
true

What it prints (run when this page was built)

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