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

ValidationErrortype

One finding of a validator: the field it is about, its code, a message, and how serious it is.

Import it

import type { ValidationError } 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 ValidationError {
    field: string;
    code: string;
    message: string;
    severity: "error" | "warning" | "info";
}

Members

NameTypeDescription
fieldstring
codestring
messagestring
severity"error" | "warning" | "info"

Examples

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

console.log(validateAddress("123 Main St, Seattle, NY 98101").warnings[0]);
// → {"field":"zip","code":"POSTAL_REGION_MISMATCH","message":"ZIP code 98101 belongs to WA, not NY","severity":"warning"}
{
  field: 'zip',
  code: 'POSTAL_REGION_MISMATCH',
  message: 'ZIP code 98101 belongs to WA, not NY',
  severity: 'warning'
}

What it prints (run when this page was built)

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