const landSet = require('./i18n-lands.js') module.exports = { validate_phone ({ phone, format } = {}) { try { if (typeof format === 'string') { return new RegExp(format).test(phone) } } catch (exp) { console.log('Invalid phone format: ', format) } try { let [fullphone, itc, callnumber] = /^\+(\d{1,4})-(\d{7,12})$/.exec(phone) for (let land of Object.values(landSet)) { if (land.itc === itc) { if (land.phoneRegex) { return new RegExp(land.phoneRegex).test(callnumber) } else { return callnumber.length > (land.phoneMinlen || 7) && callnumber.length < (land.phoneMaxlen || 12) } } } return false } catch (error) { return false } }, /* - https://regex101.com/r/3uvtNl/1 /^((?:[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~]|(?<=^|\.)"|"(?=$|\.|@)|(?<=".*)[ .](?=.*")|(?()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ */ validate_email ({ email, format } = {}) { try { if (typeof format === 'string') { return new RegExp(format).test(email) } } catch (exp) { console.log('Invalid email format: ', format) } let regex = /^((?:[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~]|(?<=^|\.)"|"(?=$|\.|@)|(?<=".*)[ .](?=.*")|(?