feat: Optimize validate message (#290)
* feat: Optimize validate message * feat: Optimize validate message
This commit is contained in:
parent
5e1a13d300
commit
35dedfd357
|
|
@ -101,7 +101,7 @@ export default function EditCluster() {
|
|||
autoComplete: 'family-name',
|
||||
value: bio,
|
||||
placeholder: 'Please enter description',
|
||||
helperText: bioError ? 'The length is 1-1000' : '',
|
||||
helperText: bioError ? 'Fill in the characters, the length is 0-1000.' : '',
|
||||
error: bioError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -128,7 +128,7 @@ export default function EditCluster() {
|
|||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter Location',
|
||||
value: location,
|
||||
helperText: locationError ? 'Maximum length is 100' : '',
|
||||
helperText: locationError ? 'Fill in the characters, the length is 0-100.' : '',
|
||||
error: locationError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -184,7 +184,7 @@ export default function EditCluster() {
|
|||
name: 'idc',
|
||||
placeholder: 'Please enter IDC',
|
||||
error: idcError,
|
||||
helperText: idcError ? 'Maximum length is 100' : '',
|
||||
helperText: idcError ? 'Fill in the characters, the length is 0-100.' : '',
|
||||
|
||||
onKeyDown: (e: any) => {
|
||||
if (e.keyCode === 13) {
|
||||
|
|
@ -228,7 +228,7 @@ export default function EditCluster() {
|
|||
name: 'cidrs',
|
||||
placeholder: 'Please enter CIDRs',
|
||||
error: cidrsError,
|
||||
helperText: cidrsError ? 'Maximum length is 1000' : '',
|
||||
helperText: cidrsError ? 'Fill in the characters, the length is 0-1000.' : '',
|
||||
|
||||
onKeyDown: (e: any) => {
|
||||
if (e.keyCode === 13) {
|
||||
|
|
@ -256,7 +256,7 @@ export default function EditCluster() {
|
|||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter Seed Peer load limit',
|
||||
value: seed_peer_cluster_config?.load_limit,
|
||||
helperText: seedPeerLoadLimitError ? 'Must be a number and range from 0-5000' : '',
|
||||
helperText: seedPeerLoadLimitError ? 'Fill in the number, the length is 0-5000.' : '',
|
||||
error: seedPeerLoadLimitError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -293,7 +293,7 @@ export default function EditCluster() {
|
|||
type: 'number',
|
||||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter Peer load limit',
|
||||
helperText: peerLoadLimitError ? 'Must be a number and range from 0-2000' : '',
|
||||
helperText: peerLoadLimitError ? 'Fill in the number, the length is 0-2000.' : '',
|
||||
error: peerLoadLimitError,
|
||||
value: load_limit,
|
||||
|
||||
|
|
@ -334,7 +334,7 @@ export default function EditCluster() {
|
|||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter Number of concurrent download pieces',
|
||||
value: concurrent_piece_count,
|
||||
helperText: numberOfConcurrentDownloadPiecesError ? 'Must be a number and range from 0-50' : '',
|
||||
helperText: numberOfConcurrentDownloadPiecesError ? 'Fill in the number, the length is 0-50.' : '',
|
||||
error: numberOfConcurrentDownloadPiecesError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -373,7 +373,7 @@ export default function EditCluster() {
|
|||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter Candidate parent limit',
|
||||
value: candidate_parent_limit,
|
||||
helperText: candidateParentLimitError ? 'Must be a number and range from 1-20' : '',
|
||||
helperText: candidateParentLimitError ? 'Fill in the number, the length is 1-20.' : '',
|
||||
error: candidateParentLimitError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -415,7 +415,7 @@ export default function EditCluster() {
|
|||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter Filter parent limit',
|
||||
value: filter_parent_limit,
|
||||
helperText: filterParentLimitError ? 'Must be a number and range from 10-1000' : '',
|
||||
helperText: filterParentLimitError ? 'Fill in the number, the length is 10-1000.' : '',
|
||||
error: filterParentLimitError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export default function NewCluster() {
|
|||
name: 'name',
|
||||
autoComplete: 'family-name',
|
||||
placeholder: 'Enter your name',
|
||||
helperText: nameError ? 'The length is 1-40' : '',
|
||||
helperText: nameError ? 'Fill in the characters, the length is 1-40.' : '',
|
||||
error: nameError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -60,7 +60,7 @@ export default function NewCluster() {
|
|||
setError: setNameError,
|
||||
|
||||
validate: (value: string) => {
|
||||
const reg = /^(?=.*[A-Za-z0-9@$!%*?&._-])[A-Za-z0-9@$!%*?&._-]{1,}$/;
|
||||
const reg = /^(?=.*[A-Za-z0-9@$!%*?&._-])[A-Za-z0-9@$!%*?&._-]{1,40}$/;
|
||||
return reg.test(value);
|
||||
},
|
||||
},
|
||||
|
|
@ -71,7 +71,7 @@ export default function NewCluster() {
|
|||
name: 'description',
|
||||
autoComplete: 'family-name',
|
||||
placeholder: 'Enter a cluster description',
|
||||
helperText: bioError ? 'The length is 1-1000' : '',
|
||||
helperText: bioError ? 'Fill in the characters, the length is 0-1000.' : '',
|
||||
error: bioError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -96,7 +96,7 @@ export default function NewCluster() {
|
|||
name: 'location',
|
||||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter location',
|
||||
helperText: locationError ? 'Maximum length is 100' : '',
|
||||
helperText: locationError ? 'Fill in the characters, the length is 0-100.' : '',
|
||||
error: locationError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -150,7 +150,7 @@ export default function NewCluster() {
|
|||
name: 'idc',
|
||||
placeholder: 'Please enter IDC',
|
||||
error: idcError,
|
||||
helperText: idcError ? 'Maximum length is 100' : '',
|
||||
helperText: idcError ? 'Fill in the characters, the length is 0-100.' : '',
|
||||
|
||||
onKeyDown: (e: any) => {
|
||||
if (e.keyCode === 13) {
|
||||
|
|
@ -196,7 +196,7 @@ export default function NewCluster() {
|
|||
name: 'cidrs',
|
||||
placeholder: 'Please enter CIDRs',
|
||||
error: cidrsError,
|
||||
helperText: cidrsError ? 'Maximum length is 1000' : '',
|
||||
helperText: cidrsError ? 'Fill in the characters, the length is 0-1000.' : '',
|
||||
|
||||
onKeyDown: (e: any) => {
|
||||
if (e.keyCode === 13) {
|
||||
|
|
@ -225,7 +225,7 @@ export default function NewCluster() {
|
|||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter Seed Peer load limit',
|
||||
defaultValue: 300,
|
||||
helperText: seedPeerLoadLimitError ? 'Must be a number and range from 0-5000' : '',
|
||||
helperText: seedPeerLoadLimitError ? 'Fill in the number, the length is 0-5000.' : '',
|
||||
error: seedPeerLoadLimitError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -260,7 +260,7 @@ export default function NewCluster() {
|
|||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter Peer load limit',
|
||||
defaultValue: 50,
|
||||
helperText: peerLoadLimitError ? 'Must be a number and range from 0-2000' : '',
|
||||
helperText: peerLoadLimitError ? 'Fill in the number, the length is 0-2000.' : '',
|
||||
error: peerLoadLimitError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -297,7 +297,7 @@ export default function NewCluster() {
|
|||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter Number of concurrent download pieces',
|
||||
defaultValue: 4,
|
||||
helperText: numberOfConcurrentDownloadPiecesError ? 'Must be a number and range from 0-2000' : '',
|
||||
helperText: numberOfConcurrentDownloadPiecesError ? 'Fill in the number, the length is 0-50.' : '',
|
||||
error: numberOfConcurrentDownloadPiecesError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -332,7 +332,7 @@ export default function NewCluster() {
|
|||
autoComplete: 'family-name',
|
||||
placeholder: 'Please enter Candidate parent limit',
|
||||
defaultValue: 4,
|
||||
helperText: candidateParentLimitError ? 'Must be a number and range from 1-20' : '',
|
||||
helperText: candidateParentLimitError ? 'Fill in the number, the length is 1-20.' : '',
|
||||
error: candidateParentLimitError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -368,7 +368,7 @@ export default function NewCluster() {
|
|||
placeholder: 'Please enter Filter parent limit',
|
||||
defaultValue: 40,
|
||||
fullWidth: false,
|
||||
helperText: filterParentLimitError ? 'Must be a number and range from 10-1000' : '',
|
||||
helperText: filterParentLimitError ? 'Fill in the number, the length is 10-1000.' : '',
|
||||
error: filterParentLimitError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export default function UpdateTokens() {
|
|||
autoComplete: 'family-name',
|
||||
placeholder: 'Enter your description',
|
||||
value: tokens.bio,
|
||||
helperText: bioError ? 'The length is 1-1000' : '',
|
||||
helperText: bioError ? 'Fill in the characters, the length is 0-1000.' : '',
|
||||
error: bioError,
|
||||
|
||||
InputProps: {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export default function CreateTokens() {
|
|||
name: 'name',
|
||||
autoComplete: 'family-name',
|
||||
placeholder: 'Enter your token name',
|
||||
helperText: nameError ? 'Please enter the correct token name' : '',
|
||||
helperText: nameError ? 'Fill in the characters, the length is 1-100.' : '',
|
||||
error: nameError,
|
||||
InputProps: {
|
||||
endAdornment: (
|
||||
|
|
@ -78,7 +78,7 @@ export default function CreateTokens() {
|
|||
setError: setNameError,
|
||||
|
||||
validate: (value: string) => {
|
||||
const reg = /^(?=.*[A-Za-z0-9@$!%*?&._-])[A-Za-z0-9@$!%*?&._-]{1,}$/;
|
||||
const reg = /^(?=.*[A-Za-z0-9@$!%*?&._-])[A-Za-z0-9@$!%*?&._-]{1,100}$/;
|
||||
return reg.test(value);
|
||||
},
|
||||
},
|
||||
|
|
@ -89,7 +89,7 @@ export default function CreateTokens() {
|
|||
name: 'bio',
|
||||
autoComplete: 'family-name',
|
||||
placeholder: 'Enter your description',
|
||||
helperText: bioError ? 'The length is 1-1000' : '',
|
||||
helperText: bioError ? 'Fill in the characters, the length is 0-1000.' : '',
|
||||
error: bioError,
|
||||
InputProps: {
|
||||
endAdornment: (
|
||||
|
|
|
|||
|
|
@ -133,8 +133,8 @@ export default function Profile() {
|
|||
name: 'bio',
|
||||
multiline: true,
|
||||
autoComplete: 'family-name',
|
||||
placeholder: 'Enter your Bio',
|
||||
helperText: bioError ? 'The length is 0-1000' : '',
|
||||
placeholder: 'Enter your description',
|
||||
helperText: bioError ? 'Fill in the characters, the length is 0-1000.' : '',
|
||||
error: bioError,
|
||||
value: user.bio,
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ export default function Profile() {
|
|||
autoComplete: 'family-name',
|
||||
value: user.phone,
|
||||
placeholder: 'Enter your Phone',
|
||||
helperText: phoneError ? 'Please enter the correct phone number' : '',
|
||||
helperText: phoneError ? 'Invalid phone number.' : '',
|
||||
error: phoneError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -202,7 +202,7 @@ export default function Profile() {
|
|||
autoComplete: 'family-name',
|
||||
value: user.location,
|
||||
placeholder: 'Enter your location',
|
||||
helperText: locationError ? 'Please enter your address' : '',
|
||||
helperText: locationError ? 'Fill in the characters, the length is 0-100.' : '',
|
||||
error: locationError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -222,7 +222,7 @@ export default function Profile() {
|
|||
setError: setLocationError,
|
||||
|
||||
validate: (value: string) => {
|
||||
const reg = /^[A-Za-z0-9]{0,1000}$/;
|
||||
const reg = /^[A-Za-z0-9]{0,100}$/;
|
||||
return reg.test(value);
|
||||
},
|
||||
},
|
||||
|
|
@ -234,7 +234,7 @@ export default function Profile() {
|
|||
autoComplete: 'family-name',
|
||||
value: user.email,
|
||||
placeholder: 'Enter your Email',
|
||||
helperText: emailError ? 'Please enter the correct email format' : '',
|
||||
helperText: emailError ? 'Email is invalid or already taken.' : '',
|
||||
error: emailError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -270,7 +270,7 @@ export default function Profile() {
|
|||
type: showOldPassword ? 'text' : 'password',
|
||||
placeholder: 'Enter your old password',
|
||||
value: old_password,
|
||||
helperText: phoneError ? 'Please enter the correct password' : '',
|
||||
helperText: phoneError ? 'Fill in the characters, the maximum length is 16.' : '',
|
||||
error: phoneError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -314,9 +314,7 @@ export default function Profile() {
|
|||
type: showNewPassword ? 'text' : 'password',
|
||||
autoComplete: 'family-name',
|
||||
placeholder: 'Enter your new password',
|
||||
helperText: locationError
|
||||
? 'At least 8-16 characters, at least 1 uppercase letter, 1 lowercase letter, and 1 number'
|
||||
: '',
|
||||
helperText: locationError ? `At least 8-16 characters, with at least 1 lowercase letter and 1 number.` : '',
|
||||
error: locationError,
|
||||
value: new_password,
|
||||
|
||||
|
|
@ -349,7 +347,7 @@ export default function Profile() {
|
|||
syncError: false,
|
||||
setError: setLocationError,
|
||||
validate: (value: string) => {
|
||||
const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/;
|
||||
const reg = /^(?=.*[a-z])(?=.*\d)[^]{8,16}$/;
|
||||
return reg.test(value);
|
||||
},
|
||||
},
|
||||
|
|
@ -361,7 +359,7 @@ export default function Profile() {
|
|||
type: showConfirmPassword ? 'text' : 'password',
|
||||
autoComplete: 'family-name',
|
||||
placeholder: 'Enter your payload',
|
||||
helperText: emailError ? 'Please enter the same password' : '',
|
||||
helperText: emailError ? 'Please enter the same password.' : '',
|
||||
error: emailError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -392,7 +390,7 @@ export default function Profile() {
|
|||
setError: setEmailError,
|
||||
|
||||
validate: (value: string) => {
|
||||
const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/;
|
||||
const reg = /^(?=.*[a-z])(?=.*\d)[^]{8,16}$/;
|
||||
return value === newPassword && reg.test(value);
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export default function SignIn() {
|
|||
name: 'account',
|
||||
autoComplete: 'family-name',
|
||||
placeholder: 'Enter your account',
|
||||
helperText: accountError ? 'Please enter the correct account number' : '',
|
||||
helperText: accountError ? 'Fill in the characters, the length is 3-10.' : '',
|
||||
error: accountError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
@ -58,7 +58,7 @@ export default function SignIn() {
|
|||
type: showPassword ? 'text' : 'password',
|
||||
autoComplete: 'password',
|
||||
placeholder: 'Enter your password',
|
||||
helperText: passwordError ? 'Please enter the correct password ' : '',
|
||||
helperText: passwordError ? 'Fill in the characters, the maximum length is 16.' : '',
|
||||
error: passwordError,
|
||||
|
||||
onChange: (e: any) => {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export default function SignUp() {
|
|||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||
const [pageLoding, setPageLoding] = useState(false);
|
||||
|
||||
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ export default function SignUp() {
|
|||
id: 'account',
|
||||
placeholder: 'Enter your account',
|
||||
error: accountError,
|
||||
helperText: accountError ? 'At least four characters do not contain special characters' : '',
|
||||
helperText: accountError ? 'Fill in the characters, the length is 3-10.' : '',
|
||||
|
||||
onChange: (e: any) => {
|
||||
changeValidate(e.target.value, formList[0]);
|
||||
|
|
@ -62,7 +62,7 @@ export default function SignUp() {
|
|||
id: 'email',
|
||||
placeholder: 'Enter your email',
|
||||
error: emailError,
|
||||
helperText: emailError ? 'Enter the correct email' : '',
|
||||
helperText: emailError ? 'Email is invalid or already taken.' : '',
|
||||
|
||||
onChange: (e: any) => {
|
||||
changeValidate(e.target.value, formList[1]);
|
||||
|
|
@ -83,9 +83,7 @@ export default function SignUp() {
|
|||
id: 'password',
|
||||
placeholder: 'Enter your password',
|
||||
autoComplete: 'new-password',
|
||||
helperText: passwordError
|
||||
? 'At least 8-16 characters, at least 1 uppercase letter, 1 lowercase letter, and 1 number'
|
||||
: '',
|
||||
helperText: passwordError ? `At least 8-16 characters, with at least 1 lowercase letter and 1 number.` : '',
|
||||
type: showPassword ? 'text' : 'password',
|
||||
error: passwordError,
|
||||
InputProps: {
|
||||
|
|
@ -112,7 +110,7 @@ export default function SignUp() {
|
|||
setError: setPasswordError,
|
||||
|
||||
validate: (value: string) => {
|
||||
const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/;
|
||||
const reg = /^(?=.*[a-z])(?=.*\d)[^]{8,16}$/;
|
||||
return reg.test(value);
|
||||
},
|
||||
},
|
||||
|
|
@ -125,7 +123,7 @@ export default function SignUp() {
|
|||
autoComplete: 'new-password',
|
||||
placeholder: 'Repeat your new password',
|
||||
error: confirmPassworError,
|
||||
helperText: confirmPassworError ? 'Please enter the same password' : '',
|
||||
helperText: confirmPassworError ? 'Please enter the same password.' : '',
|
||||
|
||||
InputProps: {
|
||||
endAdornment: (
|
||||
|
|
@ -152,7 +150,7 @@ export default function SignUp() {
|
|||
setError: setConfirmPassworError,
|
||||
|
||||
validate: (value: string) => {
|
||||
const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/;
|
||||
const reg = /^(?=.*[a-z])(?=.*\d)[^]{8,16}$/;
|
||||
return value === password && reg.test(value);
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue