fix: Fix for phone number validate
use `phone` to validate phone number with different countries Change-Id: I4f716f9df31af5f0d9643a0a48a64a13a15d2d02
This commit is contained in:
parent
30210e33c6
commit
096e6db691
@ -70,6 +70,7 @@
|
||||
"mobx-react-router": "^4.1.0",
|
||||
"moment": "^2.24.0",
|
||||
"nanoid": "^3.0.2",
|
||||
"phone": "^3.1.6",
|
||||
"promise-polyfill": "^8.1.3",
|
||||
"prop-types": "^15.7.2",
|
||||
"qs": "^6.9.4",
|
||||
|
@ -18,7 +18,7 @@ import globalUserStore from 'stores/keystone/user';
|
||||
import { ModalAction } from 'containers/Action';
|
||||
import globalProjectStore from 'stores/keystone/project';
|
||||
import globalRoleStore from 'stores/keystone/role';
|
||||
import { getPasswordOtherRule } from 'utils/validate';
|
||||
import { getPasswordOtherRule, phoneNumberValidate } from 'utils/validate';
|
||||
import globalDomainStore from 'stores/keystone/domain';
|
||||
import { statusTypes } from 'utils/constants';
|
||||
|
||||
@ -182,6 +182,7 @@ export class CreateForm extends ModalAction {
|
||||
{
|
||||
name: 'phone',
|
||||
label: t('Phone'),
|
||||
validator: phoneNumberValidate,
|
||||
type: 'input',
|
||||
required: true,
|
||||
},
|
||||
|
@ -15,6 +15,7 @@
|
||||
import { isString, isNil } from 'lodash';
|
||||
import { Address4, Address6 } from 'ip-address';
|
||||
import cidrRegex from 'cidr-regex';
|
||||
import { phone } from 'phone';
|
||||
|
||||
const { v4, v6 } = cidrRegex;
|
||||
|
||||
@ -38,8 +39,6 @@ const passwordRegex =
|
||||
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\\[\]`~!@#$%^&*()_\-+=?:"{}|,.\\/;'])[A-Za-z\d\\[\]`~!@#$%^&*()_\-+=?:"{}|,.\\/;']{8,16}$/;
|
||||
const instancePasswordRegex =
|
||||
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d\\[\]`~!@#$%^&*()_\-+=?:"{}|,.\\/;']{8,16}$/;
|
||||
const phoneNumberRegex = /^1[3456789]\d{9}$/;
|
||||
const phoneRegexp = /^(\+\d{1,3}-)(\d{7,11})?$/;
|
||||
const emailRegex =
|
||||
/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
|
||||
const nameRegexWithoutChinese = /^[a-zA-Z][\w"'\[\]^.:()_-]{0,127}$/; // eslint-disable-line
|
||||
@ -65,8 +64,6 @@ export const regex = {
|
||||
ipWithMask,
|
||||
passwordRegex,
|
||||
instancePasswordRegex,
|
||||
phoneNumberRegex,
|
||||
phoneRegexp,
|
||||
emailRegex,
|
||||
nameRegexWithoutChinese,
|
||||
fileNameRegex,
|
||||
@ -76,8 +73,7 @@ export const regex = {
|
||||
ipv6CidrOnly,
|
||||
};
|
||||
|
||||
export const isPhoneNumber = (value) =>
|
||||
phoneNumberRegex.test(value) || phoneRegexp.test(value);
|
||||
export const isPhoneNumber = (value) => phone(value).isValid;
|
||||
|
||||
export const isEmailNumber = (value) => emailRegex.test(value);
|
||||
|
||||
|
@ -10690,6 +10690,11 @@ performance-now@^2.1.0:
|
||||
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
|
||||
|
||||
phone@^3.1.6:
|
||||
version "3.1.6"
|
||||
resolved "https://registry.yarnpkg.com/phone/-/phone-3.1.6.tgz#eefff0be1ce4ce9f2ee028c67be6b58dc5616ef1"
|
||||
integrity sha512-46WCdbDG32OKoPsntTg2l0VBaWVWg0A3zvH5dUhApwOupyn7owXRtDBz6vAjsJiZQGTft++WvTxEZeqxlCUv9g==
|
||||
|
||||
picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3:
|
||||
version "2.2.3"
|
||||
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.3.tgz#465547f359ccc206d3c48e46a1bcb89bf7ee619d"
|
||||
|
Loading…
Reference in New Issue
Block a user