isValidBrazilianPostcodefunction
Whether a CEP follows the Correios' shape: eight digits, with a hyphen after the fifth or none.
Import it
import { isValidBrazilianPostcode } from "@johnmorrisdotca/address-plus/br";
Definition
function isValidBrazilianPostcode(postcode: string): boolean
Parameters
| Name | Type | Description |
|---|---|---|
postcode | string | The CEP. |
Returns
boolean
true when it has the shape.
Examples
import { isValidBrazilianPostcode } from "@johnmorrisdotca/address-plus/br";
console.log(["01310-200", "01310200", "01310-20", "1310-200"].map(isValidBrazilianPostcode));
// → [true,true,false,false][ true, true, false, false ]What it prints (run when this page was built)