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

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

NameTypeDescription
postcodestring

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)

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