Skip to content

ToErrorList doesn't return array errors #4297

@kylie-marshall

Description

@kylie-marshall

Prerequisites

What theme are you using?

core

Version

5.19.4

Current Behavior

Given the following ErrorSchema

const errorSchema = {
    "array": [
        {
            "field": {
                "__errors": [
                    "is required"
                ]
            }
        }
    ]
}
import { toErrorList } from '@rjsf/utils';
toErrorList(errorSchema); //Returns empty array

Returns empty array

Expected Behavior

Given the following ErrorSchema

const errorSchema = {
    "array": [
        {
            "field": {
                "__errors": [
                    "is required"
                ]
            }
        }
    ]
}
import { toErrorList } from '@rjsf/utils';
toErrorList(errorSchema); //Returns empty array

should return

[{
    "property": ".array.0.field", 
    "message": "is required", 
    "stack": ".array.0.field is required"
}]

Steps To Reproduce

  1. Pass ErrorSchema to form instance via extra errors with array errors
  2. ErrorListTemplate not displaying array errors

https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6eyJhcnJheSI6W3t9XSwiZmlyc3ROYW1lIjoiQ2h1Y2siLCJsYXN0TmFtZSI6Ik5vcnJpcyIsImFnZSI6NzUsImJpbyI6IlJvdW5kaG91c2Uga2lja2luZyBhc3NlcyBzaW5jZSAxOTQwIiwicGFzc3dvcmQiOiJub25lZWQifSwic2NoZW1hIjp7InR5cGUiOiJvYmplY3QiLCJwcm9wZXJ0aWVzIjp7ImJhc2ljRmllbGQiOnsidHlwZSI6InN0cmluZyIsInRpdGxlIjoiQmFzaWMgZmllbGQifSwiYXJyYXkiOnsibWluSXRlbXMiOjEsInR5cGUiOiJhcnJheSIsInRpdGxlIjoiQSBsaXN0IG9mIHN0cmluZ3MiLCJpdGVtcyI6eyJ0eXBlIjoib2JqZWN0IiwicmVxdWlyZWQiOlsiZmllbGQiXSwicHJvcGVydGllcyI6eyJmaWVsZCI6eyJ0eXBlIjoic3RyaW5nIiwidGl0bGUiOiJTdHJpbmcgZmllbGQifX19fX19LCJ1aVNjaGVtYSI6e30sInRoZW1lIjoiZGVmYXVsdCIsImxpdmVTZXR0aW5ncyI6eyJzaG93RXJyb3JMaXN0IjoidG9wIiwiZXhwZXJpbWVudGFsX2RlZmF1bHRGb3JtU3RhdGVCZWhhdmlvciI6eyJhcnJheU1pbkl0ZW1zIjp7InBvcHVsYXRlIjoicG9wdWxhdGUiLCJtZXJnZUV4dHJhRGVmYXVsdHMiOmZhbHNlfSwiYWxsT2YiOiJza2lwRGVmYXVsdHMiLCJlbXB0eU9iamVjdEZpZWxkcyI6InBvcHVsYXRlQWxsRGVmYXVsdHMifSwibm9IdG1sNVZhbGlkYXRlIjp0cnVlfX0=

image

Environment

Playground

Anything else?

My understanding is that it's treating arrays as the errors and as such is ignoring the array structure.
It's only noticeable when you define the errors in the extra errors. The errors appear correctly on the form field but are missing in the error field template

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions