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

validateGermanAddressfunction

Checks an address in Germany against Deutsche Post's postcode shape and GeoNames' list: the postcode is five digits and the list has it, and the place and the house number are given. The list is GeoNames' and not Deutsche Post's, so a postcode made since it was copied is flagged as unrecognised.

Import it

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

Definition

function validateGermanAddress(address: ParsedAddress, options?: ValidationOptions): CountryValidation

Parameters

NameTypeDescription
addressParsedAddress

The address as parseGermanAddress (or parseLocation with the module) returns it.

options (optional)ValidationOptions

strictPostalValidation: true makes the postcode findings errors; the rest are not used.

Returns

CountryValidation

The errors and warnings, each with its field, code and message.

Examples

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

const parsedAddress1=parseGermanAddress("Hauptstraße 12, 00000 Berlin");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(validateGermanAddress(parsedAddress1).warnings.map((one) => one.code));
// → ["UNRECOGNIZED_POSTAL_CODE"]
[ 'UNRECOGNIZED_POSTAL_CODE' ]

What it prints (run when this page was built)

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