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

POSTAL_CODE_TO_PROVINCEconstant

Each first letter of a Canadian postal code, to the province or territory it is assigned to. X is shared by the Northwest Territories and Nunavut and is resolved with TERRITORY_POSTAL_RANGES.

Import it

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

Definition

const POSTAL_CODE_TO_PROVINCE: Record<string, string> = {
    A: "NL",
    B: "NS",
    C: "PE",
    E: "NB",
    G: "QC",
    H: "QC",
    J: "QC",
    K: "ON",
    L: "ON",
    M: "ON",
    N: "ON",
    P: "ON",
    R: "MB",
    S: "SK",
    T: "AB",
    V: "BC",
    X: "NT",
    Y: "YT",
}

Examples

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

console.log(POSTAL_CODE_TO_PROVINCE["V"]);
// → "BC"
BC

What it prints (run when this page was built)

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