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

validateJapaneseAddressfunction

Checks 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.

Import it

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

Also exported from: @johnmorrisdotca/address-plus

Definition

function validateJapaneseAddress(address: ParsedAddress, options?: ValidationOptions): JapaneseValidation

Parameters

NameTypeDescription
addressParsedAddress

The address, as parseLocation returns it for a Japanese address.

options (optional)ValidationOptions

strictPostalValidation makes the postal findings errors rather than warnings; the municipality findings stay warnings.

Returns

JapaneseValidation

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

Examples

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

const parsedAddress1=parseLocation("〒530-0001 東京都千代田区丸の内1-2-3");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(validateJapaneseAddress(parsedAddress1).warnings.map((one) => one.code));
// → ["POSTAL_REGION_MISMATCH"]
[ 'POSTAL_REGION_MISMATCH' ]

What it prints (run when this page was built)

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