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

TERRITORY_POSTAL_RANGESconstant

The patterns that tell the Northwest Territories' X codes from Nunavut's, by their first three characters.

Import it

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

Definition

const TERRITORY_POSTAL_RANGES: { pattern: RegExp; province: string; }[] = [
    { pattern: /^Y/, province: "YT" },
    { pattern: /^X0[ABC]/, province: "NU" },
    { pattern: /^X[01]/, province: "NT" },
]

Examples

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

console.log(TERRITORY_POSTAL_RANGES.find((range) => range.pattern.test("X0A"))?.province);
// → "NU"
NU

What it prints (run when this page was built)

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