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
| Name | Type | Description |
|---|---|---|
first | ParsedAddress | The first address, as |
second | ParsedAddress | 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);
// → truetrueWhat it prints (run when this page was built)