把 validatePhone(...) 集成入 i18n-lands.js
This commit is contained in:
19
i18n.js
19
i18n.js
@@ -3,23 +3,4 @@ module.exports = {
|
||||
landSet: require('./i18n-lands.js'),
|
||||
currencySet: require('./i18n-currencies.js'),
|
||||
cryptocoinSet: require('./i18n-cryptocoins.js'),
|
||||
validatePhone ({ phone } = {}) {
|
||||
try {
|
||||
let [fullphone, areacode, callnumber] = /^\+(\d{1,3})-(\d{7,11})$/.exec(phone)
|
||||
switch (areacode) {
|
||||
case this.landSet['CN'].itc:
|
||||
return /^1\d{10}$/.test(callnumber)
|
||||
case this.landSet['SG'].itc:
|
||||
return /^[89]\d{7}$/.test(callnumber)
|
||||
case this.landSet['US'].itc:
|
||||
return /^\d{10}$/.test(callnumber)
|
||||
case this.landSet['JP'].itc:
|
||||
return /^\d{10}$/.test(callnumber)
|
||||
default:
|
||||
return true
|
||||
}
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user