-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ToErrorList doesn't return array errors #4297
Comments
@kyliem29 I'm pretty sure that errors need to be objects not arrays. Does this work for you? const errorSchema = {
"array": {
"0": {
"field": {
"__errors": [
"is required"
]
}
}
}
} Also, if you use the ErrorSchemaBuilder utility it should build proper schema for you |
Thanks for specifying that.
returns
Is the issue with the ErrorSchemaBuilder then?
|
@kyliem29 Does using the string equivalent of 0 (i.e. "0") work? I'm pretty sure the javascript object assumes all keys are strings. |
All the following still return the same invalid structure
|
I believe the issue is that the ErrorSchemaBuilder has to create the path structure.
Perhaps using lodash setWith would help to customise the creation of the arrays? |
@kyliem29 Sounds like we just need to update the API to support an array of |
Sure! This is my first contribution so please let me know if I can improve anything. |
Prerequisites
What theme are you using?
core
Version
5.19.4
Current Behavior
Given the following ErrorSchema
Returns empty array
Expected Behavior
Given the following ErrorSchema
should return
Steps To Reproduce
https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6eyJhcnJheSI6W3t9XSwiZmlyc3ROYW1lIjoiQ2h1Y2siLCJsYXN0TmFtZSI6Ik5vcnJpcyIsImFnZSI6NzUsImJpbyI6IlJvdW5kaG91c2Uga2lja2luZyBhc3NlcyBzaW5jZSAxOTQwIiwicGFzc3dvcmQiOiJub25lZWQifSwic2NoZW1hIjp7InR5cGUiOiJvYmplY3QiLCJwcm9wZXJ0aWVzIjp7ImJhc2ljRmllbGQiOnsidHlwZSI6InN0cmluZyIsInRpdGxlIjoiQmFzaWMgZmllbGQifSwiYXJyYXkiOnsibWluSXRlbXMiOjEsInR5cGUiOiJhcnJheSIsInRpdGxlIjoiQSBsaXN0IG9mIHN0cmluZ3MiLCJpdGVtcyI6eyJ0eXBlIjoib2JqZWN0IiwicmVxdWlyZWQiOlsiZmllbGQiXSwicHJvcGVydGllcyI6eyJmaWVsZCI6eyJ0eXBlIjoic3RyaW5nIiwidGl0bGUiOiJTdHJpbmcgZmllbGQifX19fX19LCJ1aVNjaGVtYSI6e30sInRoZW1lIjoiZGVmYXVsdCIsImxpdmVTZXR0aW5ncyI6eyJzaG93RXJyb3JMaXN0IjoidG9wIiwiZXhwZXJpbWVudGFsX2RlZmF1bHRGb3JtU3RhdGVCZWhhdmlvciI6eyJhcnJheU1pbkl0ZW1zIjp7InBvcHVsYXRlIjoicG9wdWxhdGUiLCJtZXJnZUV4dHJhRGVmYXVsdHMiOmZhbHNlfSwiYWxsT2YiOiJza2lwRGVmYXVsdHMiLCJlbXB0eU9iamVjdEZpZWxkcyI6InBvcHVsYXRlQWxsRGVmYXVsdHMifSwibm9IdG1sNVZhbGlkYXRlIjp0cnVlfX0=
Environment
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
The text was updated successfully, but these errors were encountered: