change itc format '+ddd-' to 'ddd'
This commit is contained in:
21
i18n-phone.js
Normal file
21
i18n-phone.js
Normal 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
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user