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
| Name | Type | Description |
|---|---|---|
address | ParsedAddress | The address as |
options (optional) | BrazilianPostFormattingOptions | Whether to add the country (see |
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)