Skip to content

Commit

Permalink
Update phone numbers in YAML files and improve phone number validation
Browse files Browse the repository at this point in the history
  • Loading branch information
metowolf committed Mar 4, 2024
1 parent d035445 commit 9e13bf5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion data/电商购物/任你购.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
basic:
organization: 任你购
cellPhone:
- +81 3-6231-7628
- +81 362317628
url: https://rennigou.jp
2 changes: 1 addition & 1 deletion data/金融银行/众安银行.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
basic:
organization: 众安银行
cellPhone:
- +852 3665-3665
- +852 36653665
url: https://bank.za.group/
12 changes: 9 additions & 3 deletions src/const/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ import Joi from 'joi'
import libphonenumber from 'google-libphonenumber'

const checkPhone = (phone) => {
let phoneStr = phone
if (/^\+\d+ /.test(phoneStr)) {
phoneStr = phoneStr.replace(/^\+\d+ /, '')
}
if (/^\d+$/.test(phoneStr)) {
return true
}
const phoneUtil = libphonenumber.PhoneNumberUtil.getInstance()
const phoneNumber = phoneUtil.parseAndKeepRawInput(phone, 'CN')
const phoneNumber = phoneUtil.parseAndKeepRawInput(phoneStr, 'CN')
return phoneUtil.isValidNumber(phoneNumber)
}

Expand All @@ -16,8 +23,7 @@ const schema = Joi.object({
return helper.message("phone is incorrect")
}
return value
}),
Joi.number()
})
).required(),
url: Joi.string().uri().optional(),
workEmail: Joi.array().items(Joi.string().email()).optional()
Expand Down

0 comments on commit 9e13bf5

Please sign in to comment.