UNPKG

ncc-prototype-email-alerts-sub

Version:

Northumberland Council Front End Email Alerts Subscription Prototype

27 lines (26 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.phoneNumberValidator = exports.selectddlValidator = exports.postCodeValidator = void 0; const postCodeRegex = /^([A-Z]{1,2}[0-9][A-Z0-9]? ?[0-9][A-Z]{2})$/i; const ukPhoneNumberRegex = /^(?:(?:\(?(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?(?:\(?0\)?[\s-]?)?)|(?:\(?0))(?:(?:\d{5}\)?[\s-]?\d{4,5})|(?:\d{4}\)?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3}))|(?:\d{3}\)?[\s-]?\d{3}[\s-]?\d{3,4})|(?:\d{2}\)?[\s-]?\d{4}[\s-]?\d{4}))(?:[\s-]?(?:x|ext\.?|#)\d{3,4})?$/; const postCodeValidator = (postcode) => { const matches = (postcode === null || postcode === void 0 ? void 0 : postcode.trim().toUpperCase().match(postCodeRegex)) || false; if (matches) { return true; } return matches; }; exports.postCodeValidator = postCodeValidator; const selectddlValidator = (selectedValue) => { const isValid = (selectedValue != '' && selectedValue != null) ? true : false; return isValid; }; exports.selectddlValidator = selectddlValidator; const phoneNumberValidator = (value) => { const isValid = value.match(ukPhoneNumberRegex) || false; if (isValid) { return true; } return isValid; }; exports.phoneNumberValidator = phoneNumberValidator;