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

formatIndiaPostfunction

Writes an address in India as India Post asks: who it is care of, the flat and the building, the house number and the street, a landmark, the area, then the city and the PIN code, then the state, each on its own line.

Import it

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

Definition

function formatIndiaPost(address: ParsedAddress, options?: IndiaPostFormattingOptions): FormattedAddress

Parameters

NameTypeDescription
addressParsedAddress

The address as parseIndianAddress returns it.

options (optional)IndiaPostFormattingOptions

Whether to add the country (see IndiaPostFormattingOptions).

Returns

FormattedAddress

The lines, the same on one line, the delivery line and the last line.

Examples

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

const parsedAddress1 = parseIndianAddress("Flat 4B, Sunshine Apartments, 12 MG Road, Indiranagar, Bengaluru, Karnataka 560038");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatIndiaPost(parsedAddress1).lines);
// → ["Sunshine Apartments","Flat 4B","12 MG Road","Indiranagar","Bengaluru 560038","Karnataka"]
[
  'Sunshine Apartments',
  'Flat 4B',
  '12 MG Road',
  'Indiranagar',
  'Bengaluru 560038',
  'Karnataka'
]

What it prints (run when this page was built)

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