UNPKG

reservease.consumer

Version:

This package allows you to create an amqplib consumer and producer.

21 lines (20 loc) 944 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PhoneNumberFormat = void 0; const InternalApiResponse_1 = require("./InternalApiResponse"); class PhoneNumberFormat { static Validate(phoneNumber) { const regex = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im; const resp = regex.test(phoneNumber); if (resp) { let newPhone = phoneNumber; if (phoneNumber.substring(0, 1).toString() === '0') newPhone = `233${phoneNumber.substring(1)}`; if (phoneNumber.substring(0, 1).toString() === '+') newPhone = phoneNumber.substring(1); return new InternalApiResponse_1.InternalApiResponse(true, newPhone, 'Successful'); } return new InternalApiResponse_1.InternalApiResponse(false, phoneNumber, 'Failed'); } } exports.PhoneNumberFormat = PhoneNumberFormat;