degachejs
Version:
A Tunisian utility library for working with CIN, phone numbers, addresses, and more
20 lines (19 loc) • 630 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validatePostalCode = void 0;
const regions_1 = require("../constants/regions");
/**
* 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 (!POSTAL_CODE_REGEX.test(postalCode))
return false;
return postalCode in regions_1.POSTAL_CODES_MAP;
};
exports.validatePostalCode = validatePostalCode;