Skip to content

Error when deleting required objects/arrays #143

Closed
@CarlosNZ

Description

@CarlosNZ

Discussed in #142

Originally posted by laurajinks December 21, 2024
Hi, I'm trying to implement an editor with validation using ajv as outlined in the demos. I have it working properly when validating editing or deleting individual required values, but I'm getting an error when deleting required objects or arrays. It seems to stem from this line here https://github.com/CarlosNZ/json-edit-react/blob/main/src/CollectionNode.tsx#L196

For example, if I had a JSON object like:

{
  "foo": {
    "bar": "baz"
  }
}

and bar was a required field, I am seeing the error messaging correctly. However if foo is a required field and I attempt to delete it, I am getting this error:

Error: Unable to extract object property
Looking for property: foo

Additionally, this is less of a big deal, but if I edit the key foo and it fails validation, It correctly does not persist the edit, however it does not show an inline error message like it does when incorrectly editing a string value.

Any thoughts on something I could be missing here?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions