Skip to content

Allow to override schema order validation error behavior #4316

@buenonadav

Description

@buenonadav

Prerequisites

What theme are you using?

material-ui

Is your feature request related to a problem? Please describe.

I am using react-jsonschema-form (RJSF) in a web application where schemas are dynamically received from the server. These schemas are user-defined and, in some cases, may be incomplete or invalid.

Specifically, when the order field in the schema is incomplete or missing a property, the application renders a hardcoded HTML error that cannot be customized or controlled.

Upon reviewing the code, it appears that a static

element is rendered in such cases, preventing any control over the error handling, customization of the error message, or modifying the template. This issue seems to originate from the following code:

https://github.com/rjsf-team/react-jsonschema-form/blob/main/packages/core/src/components/fields/ObjectField.tsx#L263

Here is an example of the UI that is generated in such scenarios:
image

Would it be possible to provide a way to handle or customize this error, such as an option to override the default behavior or allow for custom error templates?

Describe the solution you'd like

There are several potential solutions that would provide more control over schema validation errors:

  • Allow for a customizable template for schema validation errors, similar to how other TemplateTypes are handled.
  • Introduce a schema validation error handler (similar to the onError handler) that enables developers to handle these errors gracefully.
  • Provide a way to catch and manage the error programmatically, allowing for custom error handling logic.

The key requirement is gaining the ability to control or customize the behavior when these validation errors occur.

Describe alternatives you've considered

Currently, I am manually validating the order field before passing the schema to RJSF and handling any errors as needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureIs a feature requesthelp wantedtemplatesRelated to the templates capabilities of RJSF

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions