plantain-00 / schema-based-json-editor

A reactjs and vuejs component of schema based json editor.
MIT License
168 stars 38 forks source link

JavaScript error for non-required, non-existent array object members #31

Closed phispi closed 3 years ago

phispi commented 3 years ago

Thanks for the wonderful project! I ran into an issue with the following JSON schema:

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
    },
    "aliases": {
      "type": "array",
      "items": {
        "type": "string",
      }
    }
  }
}

The important thing is the aliases property and the fact that it is not required. Everything works fine as long as the aliases entry is present in the initial value:

value: {
  "name": "Michael",
  "aliases": ["Mike"]
}

However, as soon as it is omitted (which is allowed by the schema)

value: {
  "name": "Michael"
}

the browser console reports the error TypeError: _ctx.value is undefined (Firefox) or variables.js:75 Uncaught (in promise) TypeError: Cannot read property 'length' of undefined (Chromium)

The same error happens if the checkbox labeled "not exists" at the array property is checked.

Version: 8.1.0

Environment:

I hope this is the right place to report this ;-)

plantain-00 commented 3 years ago

v8.1.1 should fix this

phispi commented 3 years ago

Yes, it indeed fixes it, thank you very, very much! Very impressing how fast you investigated and fixed it! :+1: