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

Getting started

Getting started

Parse locally and inspect a nullable result.

Parse a small address

import { parseLocation } from "@johnmorrisdotca/address-plus";
const address=parseLocation("123 Main St, New York, NY 10001");
if(!address) throw new Error("This example did not parse.");
console.log(address.number,address.street,address.state,address.zip);
123 Main NY 10001

The root entry parses US, Canadian and Japanese input. Its result is structured data or null; parsing alone is not validation or a delivery guarantee. Install the package, import a function and keep your own input alongside the result if you need to show a correction. Core calls do not send the address to a service.

Add the next operation

import { validateAddress } from "@johnmorrisdotca/address-plus";
const checked=validateAddress("123 Main St, Seattle, NY 98101");
console.log(checked.isValid,checked.warnings.map(finding=>finding.code));
true [ 'POSTAL_REGION_MISMATCH' ]

A known postal-region mismatch can be a warning while the shape remains valid. Continue with validation, formatting, country modules or a form field. The original eight entry points and default parser object remain available.

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