mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-23 07:21:53 +08:00
refactor: use yup custom validator
This commit is contained in:
@@ -1,27 +1,5 @@
|
||||
import { FormSchema } from "@/types/schema.ts";
|
||||
import { InjectorConfig, ShellConfig, ShellToolConfig, ShellToolType } from "@/types/shell.ts";
|
||||
import { TFunction } from "i18next";
|
||||
|
||||
export function customValidation(t: TFunction<"translation", undefined>, values: FormSchema) {
|
||||
if (values.shellType.endsWith("Servlet") && (values.urlPattern === "/*" || !values.urlPattern)) {
|
||||
throw new Error(t("tips.servletUrlPattern"));
|
||||
}
|
||||
|
||||
if (values.shellType.endsWith("ControllerHandler") && (values.urlPattern === "/*" || !values.urlPattern)) {
|
||||
throw new Error(t("tips.controllerUrlPattern"));
|
||||
}
|
||||
|
||||
if (
|
||||
(values.shellType === "HandlerMethod" || values.shellType === "HandlerFunction") &&
|
||||
(values.urlPattern === "/*" || !values.urlPattern)
|
||||
) {
|
||||
throw new Error(t("tips.handlerUrlPattern"));
|
||||
}
|
||||
|
||||
if (values.shellTool === ShellToolType.Custom && !values.shellClassBase64) {
|
||||
throw new Error(t("tips.customShellClass"));
|
||||
}
|
||||
}
|
||||
import { InjectorConfig, ShellConfig, ShellToolConfig } from "@/types/shell.ts";
|
||||
|
||||
export function transformToPostData(formValue: FormSchema) {
|
||||
const shellConfig: ShellConfig = {
|
||||
|
||||
Reference in New Issue
Block a user