move landSet.validatePhone to i18tool.validate_phone
This commit is contained in:
23
i18n-tool.js
Normal file
23
i18n-tool.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const landSet = require('./i18n-lands.js')
|
||||
|
||||
module.exports = {
|
||||
validate_phone ({ phone } = {}) {
|
||||
try {
|
||||
let [fullphone, itc, callnumber] = /^\+(\d{1,3})-(\d{7,11})$/.exec(phone)
|
||||
switch (itc) {
|
||||
case landSet.CN.itc:
|
||||
return new RegExp(landSet.CN.reCallnumber).test(callnumber)
|
||||
case landSet.JP.itc:
|
||||
return new RegExp(landSet.JP.reCallnumber).test(callnumber)
|
||||
case landSet.SG.itc:
|
||||
return new RegExp(landSet.SG.reCallnumber).test(callnumber)
|
||||
case landSet.US.itc:
|
||||
return new RegExp(landSet.US.reCallnumber).test(callnumber)
|
||||
default:
|
||||
return true
|
||||
}
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user