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

getStateFromBrazilianPostcodefunction

The state a CEP is in, by its code (SP): the state whose range holds the CEP's first five digits.

Import it

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

Definition

function getStateFromBrazilianPostcode(postcode: string): string | undefined

Parameters

NameTypeDescription
postcodestring

The CEP.

Returns

string | undefined

The state's code, or undefined when the CEP has not the shape or no state's range holds it.

Examples

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

console.log(["01310-200", "20040-020", "70040-010", "69900-000", "00999-000"].map(getStateFromBrazilianPostcode));
// → ["SP","RJ","DF","AC",null]
[ 'SP', 'RJ', 'DF', 'AC', undefined ]

What it prints (run when this page was built)

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