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

Japanese addresses

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

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

Exports

NameKindWhat it is
findMunicipalitiesByNamefunctionThe municipalities a Japanese name could mean: several when the name is shared (府中市 is in Tokyo and in Hiroshima).
findMunicipalitiesByRomajifunctionThe municipalities a romaji name could mean, written with or without macrons and designators (Chiyoda-ku, Chiyoda City, Sapporo-shi Chuo-ku, Chuo-ku, Sapporo).
findMunicipalityByCodefunctionThe municipality with a JIS X 0402 code, a designated city's own code included.
findPrefecturefunctionThe prefecture a name, reading, romaji spelling or JIS code refers to: 東京都, 東京, トウキョウト, Tokyo, Osaka Prefecture, 13.
formatJapanesefunctionWrites a Japanese address in Japanese order, as an envelope is addressed: 〒100-0005, then 東京都千代田区丸の内1-2-3, then サンプルビル5階501号室.
formatJapaneseEnglishfunctionWrites a Japanese address in English order, as a form from abroad expects: building, room, block, town, municipality, prefecture, postal code, Japan.
getPostalPrefixesForPrefecturefunctionThe three-digit postal prefixes a prefecture's codes begin with, the reverse of getPrefectureFromJapanesePostalCode.
getPrefectureFromJapanesePostalCodefunctionThe prefecture a Japanese postal code delivers to, from Japan Post's data: by its first three digits, and for the codes on the far side of a prefix that straddles a border, by the whole code.
JapaneseAddressFieldstypeThe fields a Japanese address fills on top of the shared ones.
JapaneseEnglishFormattingOptionstypeOptions for formatJapaneseEnglish.
JapaneseFormattingOptionstypeOptions for formatJapanese.
JapaneseMunicipalitytypeA municipality (市区町村) in the tables: its JIS code, its prefecture's code, its official name with the district for a town or village in one, its reading and its romaji.
JapanesePrefecturetypeA prefecture (都道府県) in the tables: its JIS code, official name, katakana reading and romaji.
JapaneseValidationtypeWhat validateJapaneseAddress returns: the errors and the warnings found.
JP_DESIGNATED_CITIESconstantThe twenty designated cities (政令指定都市) as municipalities of their own.
JP_MUNICIPALITIESconstantEvery municipality (市区町村) by JIS X 0402 code, with its prefecture, official name, reading and romaji; a designated city's wards are listed, and the city itself is in JP_DESIGNATED_CITIES.
JP_POSTAL_EXCEPTIONSconstantThe postal codes that deliver to another prefecture than the rest of their three-digit prefix, each to that prefecture's JIS code.
JP_POSTAL_PREFIXESconstantEach three-digit postal prefix, to the JIS code of the prefecture most of its codes deliver to.
JP_PREFECTURESconstantThe 47 prefectures in JIS X 0401 order, each with its code, official name, katakana reading and romaji.
kanjiNumeralsToDigitsfunctionTurns the kanji numerals that stand for block, floor or room numbers into digits: 一丁目二番三号 becomes 1丁目2番3号.
looksJapanesefunctionWhether a text is a Japanese address: in Japanese script, ending with Japan, or naming a prefecture beside a Japanese postal code, a romaji designator (-ku, -shi) or a municipality written with an English word (Chiyoda City).
municipalitiesOffunctionEvery municipality of a prefecture, the designated cities included.
normalizeJapaneseAddressTextfunctionMakes the text of a Japanese address uniform, as the parser reads it: widths folded, spaces tidied, numerals as digits, and 1の2の3, 1-2-3 or any other dash written 1-2-3.
ParsedAddresstypeWhat parseLocation returns: every part it found, each absent when the address has none.
parseJapaneseAddressfunctionParses a Japanese address, in Japanese script or in romaji, into the Japanese fields and the shared ones.
ParseOptionstypeOptions for every parser: the country, strict postal codes, snake_case keys and the rest.
validateJapaneseAddressfunctionChecks a parsed Japanese address against the tables: the postal code's shape, whether any code begins with its first three digits, whether it delivers to the prefecture named, and whether the municipality is a real one in that prefecture.
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.