Skip to content
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

uiSchema Error: schema is invalid: data.properties['liquidity'].properties should be object, when model is in an array #109

Open
HugoKeung opened this issue Jul 29, 2021 · 5 comments

Comments

@HugoKeung
Copy link

I want to create a JSON as following
{ "stock":{ "shops":[ {"location": "high street"}, {"location": "mall"} ] }, "name":"john" }
through normal javascript, I can access the first shop detail with stock.shops[0]

I can put name under model in the uiSchema to correctly link the name (like the following)
component: "div", fieldOptions: { class: ["form-group"], }, children: [ { component: "label", fieldOptions: { attrs: { for: "name-id", }, class: ["font-weight-bold"], domProps: { innerHTML: "Name", }, }, }, { component: "input", model: "name", errorOptions: { class: ["is-invalid"], }, fieldOptions: { attrs: { id: "name-id", }, class: ["form-control"], on: ["input"], }, },

however, putting stock.shops[0] result in the following error
Error: schema is invalid: data.properties['shops'].properties should be object

How should I go about if I want to add an array for shops as shown in my example?

@dheimoz
Copy link

dheimoz commented Aug 1, 2021

Any chance to create reproduction repo to understand better?

@HugoKeung
Copy link
Author

Any chance to create reproduction repo to understand better?

https://codesandbox.io/s/example-1-forked-gdh4w

it is rendering in the sandbox (with error), but in a webpage, it will just crash (not rendering all of uiSchema)
error showing: VFJS_EVENT_FIELD_MODEL_VALIDATE schema is invalid: data.properties['liquidity'] should be object,boolean

@jarvelov
Copy link
Owner

jarvelov commented Sep 2, 2021

Hi @HugoKeung

Thanks for the reproduction. I've looked at the sandbox and confirmed the issue and written a patch. I'll release the fix in the next version, v2.9.5. It will be released this weekend.

@jarvelov
Copy link
Owner

jarvelov commented Sep 4, 2021

A fix has been released in v2.9.5 which is available now. Once small caveat however is that the model must be updated to use the dot notation syntax. I.e. instead of liquidity[0][venue] it should be written as liquidity.0.venue.

See a demo here: Demo

jarvelov added a commit that referenced this issue Sep 4, 2021
This is to ensure the path for "array" type is constructed properly, as 
Ajv doesn't want us to include the index.

See #109 for more information about the problem.
@michaelmok2021
Copy link

michaelmok2021 commented Oct 17, 2021

Hi @jarvelov , the Demo only display one venue and venue type but empty field value. Is that expected? I have a requirement to create a read only form to display schema containing array eg

{
  "success": true,
  "result": {
    "contactname": "Karina S",
    "contactemail": "karina.s@tsoft.com",
    "additiondetail": "Test Only",
    "requesttype": "New Sim",
    "simrequestdetail": [
      {
        "simserial": "1111111",
        "selectedplan": "Voice (High Data)",
        "allocation": "Division - C / Group -BC / IT",
        "username": "Kari"
      },
      {
        "simserial": "222222",
        "selectedplan": "Voice (Low Data)",
        "allocation": "Division - C / Group -BC / HR",
        "username": "Kari"
      }

    ],
    "submissiondate": "Sep 14, 2021, 9:09:31 AM",
    "contactnumber": "555 5555",
    "type": "S Request",
    "deliveryaddress": "Some address",
    "status": "Open"
  }
}

Was hoping to use your library to make it happen. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants