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

formatBrazilianPostfunction

Writes an address in Brazil as the Correios ask: who it is care of, the street with its number and the complement (Avenida Paulista, 1578, Apto 45), the bairro, then the CEP, the city and the state's code, each on its own line.

Import it

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

Definition

function formatBrazilianPost(address: ParsedAddress, options?: BrazilianPostFormattingOptions): FormattedAddress

Parameters

NameTypeDescription
addressParsedAddress

The address as parseBrazilianAddress returns it.

options (optional)BrazilianPostFormattingOptions

Whether to add the country (see BrazilianPostFormattingOptions).

Returns

FormattedAddress

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

Examples

import { formatBrazilianPost, parseBrazilianAddress } from "@johnmorrisdotca/address-plus/br";

const parsedAddress1 = parseBrazilianAddress("Av. Paulista, 1578 - Apto 45 - Bela Vista, São Paulo - SP, 01310200");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(formatBrazilianPost(parsedAddress1).lines);
// → ["Av. Paulista, 1578, Apto 45","Bela Vista","01310-200 São Paulo SP"]
[
  'Av. Paulista, 1578, Apto 45',
  'Bela Vista',
  '01310-200 São Paulo SP'
]

What it prints (run when this page was built)

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