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
| Name | Type | Description |
|---|---|---|
address | ParsedAddress | The address as |
options (optional) | ValidationOptions |
|
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)