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

AddressParsingTestCasetype

A parsing case in the package's JSON test files: an address and the fields expected from it.

Import it

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

Definition

interface AddressParsingTestCase extends TestCaseBase {
    input: string;
    expected: {
        number?: string;
        prefix?: string;
        street?: string;
        type?: string;
        suffix?: string;
        city?: string;
        state?: string;
        zip?: string;
        country?: string;
        [key: string]: unknown;
    };
    options?: {
        strict?: boolean;
        country?: string;
        [key: string]: unknown;
    };
}

Members

NameTypeDescription
inputstring
expected{ [key: string]: unknown; number?: string; prefix?: string; street?: string; type?: string; suffix?: string; city?: string; state?: string; zip?: string; country?: string; }
options (optional){ [key: string]: unknown; strict?: boolean; country?: string; } | undefined
name (optional)string | undefined
description (optional)string | undefined

Examples

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

console.log(({ input: "123 Main St, Anytown, NY 12345", expected: { number: "123", state: "NY" } }).expected.state);
// → "NY"
NY

What it prints (run when this page was built)

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