AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): Add custom validator to handle short-text and long-text formats in form renderer (#11395)
Abhimanyu Yadav184a73de7d93
diff --git a/autogpt_platform/frontend/src/components/renderers/input-renderer/FormRenderer.tsx b/autogpt_platform/frontend/src/components/renderers/input-renderer/FormRenderer.tsxindex 082b48301f..935c9e4337 100644--- a/autogpt_platform/frontend/src/components/renderers/input-renderer/FormRenderer.tsx+++ b/autogpt_platform/frontend/src/components/renderers/input-renderer/FormRenderer.tsx@@ -1,5 +1,4 @@import { BlockUIType } from "@/app/(platform)/build/components/types";-import validator from "@rjsf/validator-ajv8";import Form from "@rjsf/core";import { RJSFSchema } from "@rjsf/utils";import { fields } from "./fields";@@ -7,6 +6,7 @@ import { templates } from "./templates";import { widgets } from "./widgets";import { preprocessInputSchema } from "./utils/input-schema-pre-processor";import { useMemo } from "react";+import { customValidator } from "./utils/custom-validator";type FormContextType = {nodeId?: string;@@ -37,7 +37,7 @@ export const FormRenderer = ({<div className={"mt-4"}><Formschema={preprocessedSchema}- validator={validator}+ validator={customValidator}fields={fields}templates={templates}widgets={widgets}diff --git a/autogpt_platform/frontend/src/components/renderers/input-renderer/utils/custom-validator.ts b/autogpt_platform/frontend/src/components/renderers/input-renderer/utils/custom-validator.tsnew file mode 100644index 0000000000..d83d38560b--- /dev/null+++ b/autogpt_platform/frontend/src/components/renderers/input-renderer/utils/custom-validator.ts@@ -0,0 +1,14 @@+import { customizeValidator } from "@rjsf/validator-ajv8";++export const customValidator = customizeValidator({+ // Currently we do not have frontend side validation - we are only doing backend side validation+ // If in future we need validation on frontend - then i will add more condition here like max length, min length, etc.+ customFormats: {+ "short-text": /.*/, // Accept any string+ "long-text": /.*/,+ },+ ajvOptionsOverrides: {+ strict: false,+ validateFormats: false,+ },+});