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

DeutschePostFormattingOptionstype

Options for formatDeutschePost.

Import it

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

Definition

interface DeutschePostFormattingOptions {
    includeCountry?: boolean;
}

Members

NameTypeDescription
includeCountry (optional)boolean | undefined

Examples

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

const parsedAddress1=parseGermanAddress("Hauptstr. 12, 10115 Berlin");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatDeutschePost(parsedAddress1, { includeCountry: true }).lines);
// → ["Hauptstr. 12","10115 Berlin","DEUTSCHLAND"]
[ 'Hauptstr. 12', '10115 Berlin', 'DEUTSCHLAND' ]

What it prints (run when this page was built)

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