isCEP Function Documentation

The isCEP function checks if the input string is a valid Brazilian ZIP Code (CEP). It returns true if the CEP is valid, and false otherwise.

Import

The function can be imported using ES6 syntax from the "multiform-validator" package:

import { isCEP } from 'multiform-validator';

Alternatively, you can import the function using CommonJS syntax with require (Node.js):

const { isCEP } = require('multiform-validator');

Parameters

The function takes one parameter:

Examples

// Example 1 - Checking if the CEP is valid with dashes
const result1 = isCEP('12345-678');
console.log(result1); // true

// Example 2 - Checking if the CEP is valid without dashes
const result2 = isCEP('12345678');
console.log(result2); // true

// Example 3 - Checking an invalid CEP with an incorrect format
const result3 = isCEP('12.345-678');
console.log(result3); // false

Notes

The function expects the input to be passed as a string.