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

ParseOptionstype

Options for every parser: the country, strict postal codes, snake_case keys and the rest. Every one is optional.

Import it

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

Also exported from: @johnmorrisdotca/address-plus/au, @johnmorrisdotca/address-plus/gb, @johnmorrisdotca/address-plus/de, @johnmorrisdotca/address-plus/fr, @johnmorrisdotca/address-plus

Definition

interface ParseOptions {
    country?: "CA" | "US" | "JP" | "AU" | "GB" | "GY" | "IM" | "JE" | FrenchPostalCountry | "DE" | "GP" | "MQ" | "GF" | "RE" | "YT" | "auto";
    countries?: readonly CountryModule[];
    normalize?: boolean;
    validatePostalCode?: boolean;
    language?: "auto" | "en" | "fr";
    extractFacilities?: boolean;
    parseParenthetical?: boolean;
    strict?: boolean;
    useSnakeCase?: boolean;
}

Members

NameTypeDescription
country (optional)"CA" | "US" | "JP" | "AU" | "GB" | "GY" | "IM" | "JE" | FrenchPostalCountry | "DE" | "GP" | "MQ" | "GF" | "RE" | "YT" | "auto" | undefined
countries (optional)readonly CountryModule[] | undefined
normalize (optional)boolean | undefined
validatePostalCode (optional)boolean | undefined
language (optional)"auto" | "en" | "fr" | undefined
extractFacilities (optional)boolean | undefined
parseParenthetical (optional)boolean | undefined
strict (optional)boolean | undefined
useSnakeCase (optional)boolean | undefined

Examples

import { parseLocation } from "@johnmorrisdotca/address-plus";
import type { ParseOptions } from "@johnmorrisdotca/address-plus/jp";

console.log(Reflect.get(parseLocation("東京都千代田区丸の内1-2-3", { country: "JP", useSnakeCase: true }) ?? {}, "prefecture_code"));
// → "13"
13

What it prints (run when this page was built)

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