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
| Name | Type | Description |
|---|---|---|
postcode | string | 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)