mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 21:30:24 +08:00
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:
@ -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) {
|
||||
|
Reference in New Issue
Block a user