change itc format '+ddd-' to 'ddd'

This commit is contained in:
luk.lu
2022-12-19 12:43:58 +08:00
parent ed0f4fa45a
commit bdca922fb1
3 changed files with 275 additions and 252 deletions

21
i18n-phone.js Normal file
View File

@@ -0,0 +1,21 @@
module.exports = {
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
}
},
}