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

normalizeRegionfunction

Finds the US state or Canadian province a name, code or misspelling means: Calfornia, Que., British Columbia, nfld.

Import it

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

Definition

function normalizeRegion(input: string): { abbr: string; country: "CA" | "US"; } | null

Parameters

NameTypeDescription
inputstring

A state or province name, code or abbreviation, in English or French.

Returns

{ abbr: string; country: "CA" | "US"; } | null

Its code and country, or null when nothing is close enough.

Examples

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

console.log(normalizeRegion("Calfornia"));
// → {"abbr":"CA","country":"US"}
{ abbr: 'CA', country: 'US' }

What it prints (run when this page was built)

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