react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

Invalid values when adding property with multiple possible value types (e.g. nullable ["object", "null"])

Open cosborne83 opened this issue 3 years ago • 12 comments

Prerequisites

Description

Invalid form data when adding additionalProperties where the values are of multiple possible types (e.g. ["object", "null"])

Steps to Reproduce

  1. Open this playground link.
  2. Click the "+" button to add a new property to "DictProp"
  3. Set the Value property of the newly added value on the form.

Expected behavior

At step 2 above, either the new value in the formData should be one of the valid types (object/null). At step 3 above, the properties of newKey should not contain the characters of "New Value" expanded out into properties on the object.

Actual behavior

At step 2 above, the formData now includes an invalid property: "newKey": "New Value" that does not match the schema (the values for additional properties must be object or null, but the value added is a string:

{
  "DictProp": {
    "newKey": "New Value"
  }
}

At step 3 above, the formData now includes the string "New Value" expanded out character-by-character as numbered properties of the object:

{
  "DictProp": {
    "newKey": {
      "0": "N",
      "1": "e",
      "2": "w",
      "3": " ",
      "4": "V",
      "5": "a",
      "6": "l",
      "7": "u",
      "8": "e",
      "Value": "X"
    }
  }
}

Version

3.2.1

cosborne83 avatar Jan 24 '22 12:01 cosborne83

Hello @jacqueswho , Would like to know the update on this issue. Thanks.

Sachin-chaurasiya avatar Oct 18 '22 16:10 Sachin-chaurasiya

@Sachin-chaurasiya I will bring it up in the next meeting

jacqueswho avatar Oct 18 '22 16:10 jacqueswho

@Sachin-chaurasiya I will bring it up in the next meeting

That would be great, thanks @jacqueswho

Sachin-chaurasiya avatar Oct 18 '22 16:10 Sachin-chaurasiya

Hello @jacqueswho , Hope you are doing well, Is there any update on this issue?

Sachin-chaurasiya avatar Nov 25 '22 06:11 Sachin-chaurasiya

Hello @jacqueswho , Hope you are doing well, Is there any update on this issue?

@Sachin-chaurasiya apologies, but work has been quite busy, not been in the last 2 meetings, also there was a public holiday. Will check on what was discussed

jacqueswho avatar Nov 25 '22 15:11 jacqueswho

Hello @jacqueswho , Hope you are doing well, Is there any update on this issue?

@Sachin-chaurasiya apologies, but work has been quite busy, not been in the last 2 meetings, also there was a public holiday. Will check on what was discussed

Thanks, @jacqueswho, It would be great if you provide me with some work around for this.

Sachin-chaurasiya avatar Nov 25 '22 15:11 Sachin-chaurasiya

@Sachin-chaurasiya Sorry it took so long. I have investigated this, had a look at the code, according to the docs, you cant specify object as a type for this. So if you look at this playground link . It works as expected, not sure what you were expecting

jacqueswho avatar Dec 08 '22 17:12 jacqueswho

@Sachin-chaurasiya Sorry it took so long. I have investigated this, had a look at the code, according to the docs, you cant specify object as a type for this. So if you look at this playground link . It works as expected, not sure what you were expecting

Thanks @jacqueswho , I will have a look.

Sachin-chaurasiya avatar Dec 08 '22 17:12 Sachin-chaurasiya

@Sachin-chaurasiya Sorry it took so long. I have investigated this, had a look at the code, according to the docs, you cant specify object as a type for this. So if you look at this playground link . It works as expected, not sure what you were expecting

Hello @jacqueswho , How can we get rid of this default values in additional properties? image

Sachin-chaurasiya avatar Dec 10 '22 05:12 Sachin-chaurasiya

@Sachin-chaurasiya Sorry it took so long. I have investigated this, had a look at the code, according to the docs, you cant specify object as a type for this. So if you look at this playground link . It works as expected, not sure what you were expecting

Hello @jacqueswho , How can we get rid of this default values in additional properties? image

Hi @jacqueswho Is there a way of hack that will allow us to remove this values to be populated?

chirag-madlani avatar Dec 22 '22 10:12 chirag-madlani

Hi @jacqueswho

I have investigated this and figured out that we have Hardcoded "newKey" here

Can we provide an option to override it?

The same goes for value too, look here

We need some way to override these values as adding a new field renders these hardcoded strings.

Any help or hack is appriciated

chirag-madlani avatar Jan 12 '23 05:01 chirag-madlani

This issue has been automatically marked as possibly close because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.

stale[bot] avatar Apr 12 '24 22:04 stale[bot]

This issue was closed because of lack of recent activity. Reopen if you still need assistance.

stale[bot] avatar May 13 '24 21:05 stale[bot]