move landSet.validatePhone to i18tool.validate_phone
This commit is contained in:
parent
8eba84d1b9
commit
127674b32d
@ -2,25 +2,6 @@
|
|||||||
// https://www.iso.org/obp/ui/#search
|
// https://www.iso.org/obp/ui/#search
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
validatePhone ({ phone } = {}) {
|
|
||||||
try {
|
|
||||||
let [fullphone, itc, callnumber] = /^\+(\d{1,3})-(\d{7,11})$/.exec(phone)
|
|
||||||
switch (itc) {
|
|
||||||
case this.CN.itc:
|
|
||||||
return new RegExp(this.CN.reCallnumber).test(callnumber)
|
|
||||||
case this.SG.itc:
|
|
||||||
return new RegExp(this.CN.reCallnumber).test(callnumber)
|
|
||||||
case this.US.itc:
|
|
||||||
return new RegExp(this.CN.reCallnumber).test(callnumber)
|
|
||||||
case this.JP.itc:
|
|
||||||
return new RegExp(this.CN.reCallnumber).test(callnumber)
|
|
||||||
default:
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
AD: {
|
AD: {
|
||||||
domain: 'ad',
|
domain: 'ad',
|
||||||
emoji: '🇦🇩',
|
emoji: '🇦🇩',
|
||||||
|
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
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
1
i18n.js
1
i18n.js
@ -3,4 +3,5 @@ module.exports = {
|
|||||||
landSet: require('./i18n-lands.js'),
|
landSet: require('./i18n-lands.js'),
|
||||||
currencySet: require('./i18n-currencies.js'),
|
currencySet: require('./i18n-currencies.js'),
|
||||||
cryptocoinSet: require('./i18n-cryptocoins.js'),
|
cryptocoinSet: require('./i18n-cryptocoins.js'),
|
||||||
|
i18tool: require('./i18n-tool.js'),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user