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 · British country module

RoyalMailFormattingOptionstype

Options for formatRoyalMail.

Import it

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

Definition

interface RoyalMailFormattingOptions {
    includeCounty?: boolean;
    includeCountry?: boolean;
}

Members

NameTypeDescription
includeCounty (optional)boolean | undefined
includeCountry (optional)boolean | undefined

Examples

import { formatRoyalMail, parseUKAddress } from "@johnmorrisdotca/address-plus/gb";
import type { RoyalMailFormattingOptions } from "@johnmorrisdotca/address-plus/gb";

const parsedAddress1=parseUKAddress("10 Downing Street, London SW1A 2AA");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatRoyalMail(parsedAddress1, { includeCountry: true }).lines);
// → ["10 Downing Street","LONDON","SW1A 2AA","UNITED KINGDOM"]
[ '10 Downing Street', 'LONDON', 'SW1A 2AA', 'UNITED KINGDOM' ]

What it prints (run when this page was built)

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