From 9e13bf5ff3ca7de9039752d6553acf14361117f0 Mon Sep 17 00:00:00 2001 From: METO Date: Mon, 4 Mar 2024 11:58:51 +0000 Subject: [PATCH] Update phone numbers in YAML files and improve phone number validation --- .../\344\273\273\344\275\240\350\264\255.yaml" | 2 +- ...274\227\345\256\211\351\223\266\350\241\214.yaml" | 2 +- src/const/schema.js | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git "a/data/\347\224\265\345\225\206\350\264\255\347\211\251/\344\273\273\344\275\240\350\264\255.yaml" "b/data/\347\224\265\345\225\206\350\264\255\347\211\251/\344\273\273\344\275\240\350\264\255.yaml" index f796e721..78e7f655 100644 --- "a/data/\347\224\265\345\225\206\350\264\255\347\211\251/\344\273\273\344\275\240\350\264\255.yaml" +++ "b/data/\347\224\265\345\225\206\350\264\255\347\211\251/\344\273\273\344\275\240\350\264\255.yaml" @@ -1,5 +1,5 @@ basic: organization: 任你购 cellPhone: - - +81 3-6231-7628 + - +81 362317628 url: https://rennigou.jp \ No newline at end of file diff --git "a/data/\351\207\221\350\236\215\351\223\266\350\241\214/\344\274\227\345\256\211\351\223\266\350\241\214.yaml" "b/data/\351\207\221\350\236\215\351\223\266\350\241\214/\344\274\227\345\256\211\351\223\266\350\241\214.yaml" index f6936679..d3c8fd75 100644 --- "a/data/\351\207\221\350\236\215\351\223\266\350\241\214/\344\274\227\345\256\211\351\223\266\350\241\214.yaml" +++ "b/data/\351\207\221\350\236\215\351\223\266\350\241\214/\344\274\227\345\256\211\351\223\266\350\241\214.yaml" @@ -1,5 +1,5 @@ basic: organization: 众安银行 cellPhone: - - +852 3665-3665 + - +852 36653665 url: https://bank.za.group/ diff --git a/src/const/schema.js b/src/const/schema.js index 8c843c93..dbc602f4 100644 --- a/src/const/schema.js +++ b/src/const/schema.js @@ -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) } @@ -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()