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 · Parsing, formatting and shared types

AddressComparisonOptionstype

Options for comparing addresses: what to normalize before comparing, whether to allow small typos, and whether every field must match exactly.

Import it

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

Definition

interface AddressComparisonOptions {
    ignoreCase?: boolean;
    ignorePunctuation?: boolean;
    normalizeStreetTypes?: boolean;
    normalizeDirections?: boolean;
    normalizeStates?: boolean;
    fuzzyMatching?: boolean;
    strictPostalCode?: boolean;
    requireExactMatch?: boolean;
}

Members

NameTypeDescription
ignoreCase (optional)boolean | undefined
ignorePunctuation (optional)boolean | undefined
normalizeStreetTypes (optional)boolean | undefined
normalizeDirections (optional)boolean | undefined
normalizeStates (optional)boolean | undefined
fuzzyMatching (optional)boolean | undefined
strictPostalCode (optional)boolean | undefined
requireExactMatch (optional)boolean | undefined

Examples

import { isSameAddress, parseLocation } from "@johnmorrisdotca/address-plus";
import type { AddressComparisonOptions } from "@johnmorrisdotca/address-plus";

const parsedAddress1=parseLocation("123 Main St, Anytown, NY 12345");
if (!parsedAddress1) throw new Error("The example address did not parse.");
const parsedAddress2=parseLocation("123 Main Stret, Anytown, NY 12345");
if (!parsedAddress2) throw new Error("The example address did not parse.");
console.log(isSameAddress(parsedAddress1, parsedAddress2, { fuzzyMatching: false }));
// → false
false

What it prints (run when this page was built)

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