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 · /in

IndiaPostFormattingOptionstype

Options for formatIndiaPost.

Import it

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

Definition

interface IndiaPostFormattingOptions {
    includeCountry?: boolean;
}

Members

NameTypeDescription
includeCountry (optional)boolean | undefined

Examples

import { formatIndiaPost, parseIndianAddress } from "@johnmorrisdotca/address-plus/in";
import type { IndiaPostFormattingOptions } from "@johnmorrisdotca/address-plus/in";

const options: IndiaPostFormattingOptions = { includeCountry: true };
const parsedAddress1 = parseIndianAddress("12 MG Road, Bengaluru 560001");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatIndiaPost(parsedAddress1, options).lines);
// → ["12 MG Road","Bengaluru 560001","Karnataka","INDIA"]
[ '12 MG Road', 'Bengaluru 560001', 'Karnataka', 'INDIA' ]

What it prints (run when this page was built)

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