feat: fix bug that signup country code is undefined (#1590)

* feat: fix signup country code is undefined

* refactor: valid phone number in CN
This commit is contained in:
Yaodong Yu
2023-02-27 20:10:59 +08:00
committed by GitHub
parent f5672357e6
commit 5caceb4ae2
8 changed files with 27 additions and 30 deletions

View File

@ -349,13 +349,15 @@ export function isValidEmail(email) {
}
export function isValidPhone(phone, countryCode = "") {
if (countryCode !== "") {
if (countryCode !== "" && countryCode !== "CN") {
return phoneNumber.isValidPhoneNumber(phone, countryCode);
}
// // https://learnku.com/articles/31543, `^s*$` filter empty email individually.
// https://learnku.com/articles/31543, `^s*$` filter empty email individually.
const phoneCnRegex = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
const phoneRegex = /[0-9]{4,15}$/;
return phoneRegex.test(phone);
return countryCode === "CN" ? phoneCnRegex.test(phone) : phoneRegex.test(phone);
}
export function isValidInvoiceTitle(invoiceTitle) {