UNPKG

validations-br

Version:
14 lines (13 loc) 591 B
//#region src/validations/validateCep.ts /** * The function `validateCep` validates a Brazilian CEP (postal code) using a regular expression. * @param {string} cep - The `cep` parameter is a string that represents the CEP (Código de * Endereçamento Postal - Postal Addressing Code) to be validated. * @returns The `validateCep` function returns a boolean value. It returns `true` if the provided `cep` * is a valid CEP, and `false` otherwise. */ function validateCep(cep) { return typeof cep === "string" && /^([\d]{8}|[\d]{5}-[\d]{3})$/.test(cep); } //#endregion export { validateCep };