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

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

12.2 kB minified and gzipped, with everything it imports (measured with esbuild)

Exports

NameKindWhat it is
compareGermanAddressesfunctionCompares 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.
CountryComparisontypeWhat a country module's comparer returns: whether the two addresses are the same delivery point, and every field that differs once both are in the same form (letter case, punctuation, a street type written out or abbreviated).
CountryDifferencetypeOne way two addresses differ, as a country module's comparer reports it: the field, and its value in each address after both were put in the same form.
CountryModuletypeA country's address module: its codes, how to tell its addresses apart, and its parser, validator, formatter and comparer.
CountryValidationtypeWhat a country module's validator returns: the errors and the warnings it found.
DE_BUILDING_WORDSconstantThe words for a part of a building, which open the line the parser keeps whole as building (Hinterhaus, Haus B, Gebäude 4, Block C), in lower case.
DE_COUNTRY_NAMESconstantWhat a country at the end of an address may be called, in capitals with no umlauts: DEUTSCHLAND, GERMANY, ALLEMAGNE, BRD.
DE_STATESconstantThe sixteen Länder of Germany, in order of their codes, each with its ISO 3166-2 code and its name in English and in Japanese.
DE_STREET_OPENERSconstantThe words that begin a street's name with no suffix to end it (Am Markt, An der Weide, Zum alten Hof, Im Winkel), and the adjectives that begin one (Große Bleiche, Alte Dorfstraße), in lower case.
DE_STREET_SUFFIXESconstantWhat a street's name may end with, which makes the word the name ends in a thoroughfare (Hauptstraße, Berliner Str., Kastanienallee), in lower case with their spellings: strasse for straße, str for the abbreviation.
DE_UNIT_TYPESconstantThe words for a flat or a room, which the parser reports as secUnitType in full, with the abbreviations it reads for each: `Whg.
DeutschePostFormattingOptionstypeOptions for formatDeutschePost.
findGermanStatefunctionFinds a Land of Germany by its code (BY, DE-BY) or its name in English, German or Japanese, without regard to letter case or umlauts written as ae, oe, ue.
formatDeutschePostfunctionWrites 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.
FormattedAddresstypeA formatted address: its lines, and the same on one line.
GermanAddressFieldstypeThe fields an address in Germany fills beside the shared ones.
GermanPostcodetypeA postcode taken apart: the Land it is in, and whether GeoNames' list has it.
GermanStatetypeA Land of Germany in the tables: its code, its ISO 3166-2 code, and its name in English and in Japanese (from kuni, which takes them from Unicode CLDR and Wikidata).
GermanStateCodetypeThe code of one of the sixteen Länder of Germany, as ISO 3166-2:DE writes it after DE-.
germanyconstantGermany's module, for parseLocation and validateAddress: pass it in countries, and an address that ends with Germany or Deutschland, or has a German street and its number and a postcode first on its last line, is read as German; country: "DE" reads any address as one.
getStateFromGermanPostcodefunctionThe Land a postcode is in, by its code: BY for 80331, BE for 10115.
isKnownGermanPostcodefunctionWhether GeoNames' list for Germany has a postcode (its places include those of large firms, whose postcodes are their own).
isValidGermanPostcodefunctionWhether a postcode follows Deutsche Post's shape: five digits.
looksGermanfunctionWhether an address is surely German, with no hint: it ends with Germany, Deutschland or a code such as D-10115 before the place, or its last line begins with a postcode and a place (10115 Berlin) while the address has a street that ends in a German suffix (Hauptstraße, Kastanienallee, Am Markt) followed by its number, or a Postfach or a Packstation.
ParsedAddresstypeWhat parseLocation returns: every part it found, each absent when the address has none.
parseGermanAddressfunctionParses an address in Germany into the parts Deutsche Post and DIN 5008 lay out: who it is care of (careOf, from c/o, `z.
parseGermanPostcodefunctionTakes a postcode apart: the Land it is in, from GeoNames' list (a postcode with places in two Länder takes the one most are in), and whether the list has it.
ParseOptionstypeOptions for every parser: the country, strict postal codes, snake_case keys and the rest.
validateGermanAddressfunctionChecks 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.
ValidationErrortypeOne finding of a validator: the field it is about, its code, a message, and how serious it is.
ValidationOptionstypeOptions for the validators: which parts an address must have, which kinds are allowed, and whether a postal code that does not match its region is an error.

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