chore: remove validators on the frontend (#1156)

* chore: update minlength of username

* remove the validator on frontend

* update
This commit is contained in:
Zeng1998
2023-02-25 14:59:29 +08:00
committed by GitHub
parent e64245099c
commit 57479b250a
7 changed files with 16 additions and 130 deletions

View File

@ -2,20 +2,12 @@ import { isEqual } from "lodash-es";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useUserStore } from "../store/module";
import { validate, ValidatorConfig } from "../helpers/validator";
import { convertFileToBase64 } from "../helpers/utils";
import Icon from "./Icon";
import { generateDialog } from "./Dialog";
import toastHelper from "./Toast";
import UserAvatar from "./UserAvatar";
const validateConfig: ValidatorConfig = {
minLength: 4,
maxLength: 320,
noSpace: true,
noChinese: true,
};
type Props = DialogProps;
interface State {
@ -100,12 +92,6 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
return;
}
const usernameValidResult = validate(state.username, validateConfig);
if (!usernameValidResult.result) {
toastHelper.error(t("common.username") + ": " + t(usernameValidResult.reason as string));
return;
}
try {
const user = userStore.getState().user as User;
const userPatch: UserPatch = {