Skip to content

Error not propagated when raising errors from a custom widget or field #4382

@guilhermecastros

Description

@guilhermecastros

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

Error messages are not being propagated correctly for json object schemas.

For instance I have these two schemas, when I raise a custom error with schema2 it works nice as expected & described on the documentation. But when I do the same, but for schema which has a type object it doesn't work.

export const schema: RJSFSchema = {
  properties: {
    Test: {
      type: "number",
      title: "Test 1",
    },
    Test2: {
      type: "number",
      title: "Test 2",
    },
  },
  type: "object",
};
export const schema2: RJSFSchema = {
  type: "string",
  default: "hello",
};

I have created the following playground that allows you to play & to check the current behavior ⬇️

https://codesandbox.io/p/sandbox/rjsf-custom-error-ql66mh?workspaceId=7d9d1079-911b-4954-9a3d-7c3de5279f0c

image

image

Expected Behavior

Custom errors should show regardless of the schema used, which means it should show on both described scenarios.

Steps To Reproduce

  1. Open playground.
  2. You will see that I am rendering two schemas.
  3. Type something on each field
  4. You will see that for the schema of type object, no error is shown.

Environment

- OS:
- Node:
- npm:

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions