Skip to content

Commit 184a73d

Browse files
authored
fix(frontend): Add custom validator to handle short-text and long-text formats in form renderer (#11395)
The rfjs library was throwing validation errors for our custom format types `short-text` and `long-text` because these are not standard JSON Schema formats. This was causing form validation to fail even though these formats are valid in our application context. <img width="792" height="85" alt="Screenshot 2025-11-18 at 9 39 08 AM" src="https://github.com/user-attachments/assets/c75c584f-b991-483c-8779-fc93877028e0" /> ### Changes 🏗️ - Created a custom validator using `@rjsf/validator-ajv8`'s `customizeValidator` function - Added support for `short-text` and `long-text` custom formats that accept any string value - Replaced the default validator with our custom validator in the FormRenderer component - Disabled strict mode and format validation in AJV options to prevent validation errors for non-standard formats ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Create an agent with input blocks that use short-text format - [x] Create an agent with input blocks that use long-text format - [x] Execute the agent and verify no validation errors appear - [x] Verify that form submission works correctly with both formats - [x] Test that other standard formats (email, URL, etc.) still work as expected
1 parent 1154f86 commit 184a73d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

autogpt_platform/frontend/src/components/renderers/input-renderer/FormRenderer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { BlockUIType } from "@/app/(platform)/build/components/types";
2-
import validator from "@rjsf/validator-ajv8";
32
import Form from "@rjsf/core";
43
import { RJSFSchema } from "@rjsf/utils";
54
import { fields } from "./fields";
65
import { templates } from "./templates";
76
import { widgets } from "./widgets";
87
import { preprocessInputSchema } from "./utils/input-schema-pre-processor";
98
import { useMemo } from "react";
9+
import { customValidator } from "./utils/custom-validator";
1010

1111
type FormContextType = {
1212
nodeId?: string;
@@ -37,7 +37,7 @@ export const FormRenderer = ({
3737
<div className={"mt-4"}>
3838
<Form
3939
schema={preprocessedSchema}
40-
validator={validator}
40+
validator={customValidator}
4141
fields={fields}
4242
templates={templates}
4343
widgets={widgets}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { customizeValidator } from "@rjsf/validator-ajv8";
2+
3+
export const customValidator = customizeValidator({
4+
// Currently we do not have frontend side validation - we are only doing backend side validation
5+
// If in future we need validation on frontend - then i will add more condition here like max length, min length, etc.
6+
customFormats: {
7+
"short-text": /.*/, // Accept any string
8+
"long-text": /.*/,
9+
},
10+
ajvOptionsOverrides: {
11+
strict: false,
12+
validateFormats: false,
13+
},
14+
});

0 commit comments

Comments
 (0)