react-json-editor icon indicating copy to clipboard operation
react-json-editor copied to clipboard

Handling of integer value of zero

Open amitsrivastava opened this issue 10 years ago • 5 comments

Integer value of zero is being set to blank in React due to improper handling of these values. I add a function in objectUtils.js though I am not sure if that's the best place to keep it.

I had to revert a validation changes and it was throwing exception for me. You may ignore that revert if things are looking good to you.

amitsrivastava avatar Jan 29 '16 20:01 amitsrivastava

The commit "Validate properties from oneOf (86979b6)" is throwing me the following exception and that is why I had to revert it.

Uncaught TypeError: validator[type] is not a function

amitsrivastava avatar Jan 29 '16 20:01 amitsrivastava

I can't replicate your issue. In http://ismaelga.github.io/react-json-editor/ 0 is parsed correctly both with number and integer types.

Use this schema to test it yourself

{
  "type": "object",
  "properties": {
    "integer": {
      "title": "Integer",
      "type": "integer"
    },
    "number": {
      "title": "Number",
      "type": "number"
     }
  }
}

ismaelga avatar Jan 29 '16 20:01 ismaelga

Strange. I tried the schema you just provided and fields show up as blank for me. I am passing {"integer": 0, "number": 0.0} as value.

amitsrivastava avatar Jan 29 '16 21:01 amitsrivastava

Oh ok. I was testing it in a different way. I will try that later

On 29 Jan 2016, at 21:25, Amit Srivastava [email protected] wrote:

Strange. I tried the schema you just provided and fields show up as blank for me. I am passing {"integer": 0, "number": 0.0} as value.

— Reply to this email directly or view it on GitHub https://github.com/ismaelga/react-json-editor/pull/16#issuecomment-176975369.

ismaelga avatar Jan 29 '16 21:01 ismaelga

Can you send a new PR without the "Revert "Validate properties from oneOf"? I will fix it before merging

ismaelga avatar Feb 01 '16 12:02 ismaelga