u
This commit is contained in:
20
i18n-tool.js
20
i18n-tool.js
@@ -1,11 +1,19 @@
|
||||
const landSet = require('./i18n-lands.js')
|
||||
|
||||
module.exports = {
|
||||
validate_phone ({ phone, level = wo?.envar?.phoneStrict || wo?.ss?.envarRemote?.phoneStrict || 'LEN' } = {}) {
|
||||
validate_phone ({ phone, format } = {}) {
|
||||
try {
|
||||
if (typeof format === 'string') {
|
||||
return new RegExp(format).test(callnumber)
|
||||
}
|
||||
} catch (exp) {
|
||||
console.log('Invalid phone format: ', format)
|
||||
}
|
||||
|
||||
try {
|
||||
let [fullphone, itc, callnumber] = /^\+(\d{1,4})-(\d{7,12})$/.exec(phone)
|
||||
let landSet = wo?.i18n?.landSet || wo?.ss?.i18n?.landSet || {}
|
||||
for (let land of Object.values(landSet)) {
|
||||
if (land.itc === itc) {
|
||||
console.log(land)
|
||||
if (land.phoneRegex) {
|
||||
return new RegExp(land.phoneRegex).test(callnumber)
|
||||
} else {
|
||||
@@ -26,16 +34,16 @@ module.exports = {
|
||||
/^(([^<>()\[\]\\.,;:\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 } = {}) {
|
||||
let regex =
|
||||
/^((?:[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~]|(?<=^|\.)"|"(?=$|\.|@)|(?<=".*)[ .](?=.*")|(?<!\.)\.){1,64})(@)((?:[A-Za-z0-9.\-])*(?:[A-Za-z0-9])\.(?:[A-Za-z0-9]){2,})$/
|
||||
try {
|
||||
if (typeof format === 'string') {
|
||||
regex = new RegExp(format)
|
||||
return new RegExp(format).test(email)
|
||||
}
|
||||
} catch (exp) {
|
||||
console.log('Invalid email format: ', format)
|
||||
}
|
||||
|
||||
let regex =
|
||||
/^((?:[A-Za-z0-9!#$%&'*+\-\/=?^_`{|}~]|(?<=^|\.)"|"(?=$|\.|@)|(?<=".*)[ .](?=.*")|(?<!\.)\.){1,64})(@)((?:[A-Za-z0-9.\-])*(?:[A-Za-z0-9])\.(?:[A-Za-z0-9]){2,})$/
|
||||
return regex.test(email)
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user