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

formatDeutschePostfunction

Writes an address in Germany as Deutsche Post asks: who it is care of (c/o), the part of the building, the flat and the floor, the street and its house number, then the postcode and the place, each on its own line, with no punctuation at the end of a line. A Postfach is written with its number in pairs (Postfach 12 34 56) and a Packstation with its number.

Import it

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

Definition

function formatDeutschePost(address: ParsedAddress, options?: DeutschePostFormattingOptions): FormattedAddress

Parameters

NameTypeDescription
addressParsedAddress

The address as parseGermanAddress returns it.

options (optional)DeutschePostFormattingOptions

Whether to add the country (see DeutschePostFormattingOptions).

Returns

FormattedAddress

The lines, the same on one line, the delivery line (the street and its number) and the last line.

Examples

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

const parsedAddress1=parseGermanAddress("Hinterhaus, 2. OG, Kastanienallee 4 b, 10435 Berlin");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatDeutschePost(parsedAddress1).lines);
// → ["Hinterhaus","2. OG","Kastanienallee 4B","10435 Berlin"]
[ 'Hinterhaus', '2. OG', 'Kastanienallee 4B', '10435 Berlin' ]

What it prints (run when this page was built)

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