degachejs
Version:
A Tunisian utility library for working with CIN, phone numbers, addresses, and more
22 lines (21 loc) • 669 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validatePostalCode = void 0;
const constants_1 = require("../constants");
/**
* Regular expression for postal code validation
*/
const POSTAL_CODE_REGEX = /^\d{4}$/;
/**
* Validates a Tunisian postal code
* @param postalCode - The postal code to validate
* @returns boolean indicating if the postal code is valid
*/
const validatePostalCode = (postalCode) => {
if (!postalCode)
return false;
if (!POSTAL_CODE_REGEX.test(postalCode))
return false;
return postalCode in constants_1.POSTAL_CODES_MAP;
};
exports.validatePostalCode = validatePostalCode;