-
-
Notifications
You must be signed in to change notification settings - Fork 31
Feature request: Selection of object properties/keys with values of the correct type. #141
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
Comments
This request appears to be related to this one: |
Okay, couple of things:
So here is a modification with the correct schema a string default and it's working as expected when adding the https://codesandbox.io/p/sandbox/json-edit-react-demo-forked-wqsmkc?file=%2Fsrc%2FApp.js%3A47%2C26 Hope that helps :) |
Thank you for your kind reply even for a silly mistake.
My intuition is that when I provide a JSON Schema, I have to provide a |
No problem. Sorry, I posted my local link rather than the public demo: https://carlosnz.github.io/json-edit-react/?data=customNodes
Yes, it would be good to have default values generated automatically, but adding this into the core package is beyond the scope of what this tool should do for now. We can do JSON schema validation, but the actual validation is done by an external tool, so I imagine something similar could be done for this. It would involve fairly complicated JSON schema parsing, so I wouldn't want to include it in the main package, but if someone wanted to create one, it could be a good supplement. You'd need to write a function to input a JSON schema and output a "DefaultValueFilterFunction" -- definitely a non-trivial task. I might have a crack at it one day, but it'd be great if someone wanted to contribute one. |
@CarlosNZ How much of JSON schema do you want supported in this. I ended up creating something like this for my self, which resolves a sub schema based on the path. Then if it finds a default in the schema, it uses it, otherwise, it generates one if it can (single level generation for object properties). There are limitations to this, (imagine trying to auto-generate a default for oneOf schema), so I'm wondering what kind of scope you'd like to see for this, and how you'd prefer it to be published. PS: just found this package today which has been really helpful for something I'm working on. Thanks! |
Thanks for the feedback. I dont't think I want to add any more JSON schema functionality to the package itself, as there are plenty of external tools to handle that that can integrate nicely with this component. But I was imagining someone developing some additional bit of code that could generate the required json-edit-react filter and restriction functions based on a schema. Would be quite tricky I think, and I'd probably advise waiting until I've had a chance to implement a bit more like this issue, and this one which is similar. |
Done in #183 and released in v1.25.0 @PrimoUomo89 -- I've started working on a script to take a JSON Schema and return all the function props required for this component to implement it. |
Describe the Difficulty
When entering a key to add, the default value is maybe null, so it is rejected by validate.
I'm imitating the onUpdate validation in the demo source code. But I can't add a value because it's rejected by that validation.
Describe the Request
When entering a key to add, it would be nice if the appropriate value was already entered.
Online demo
I'm imitating the jsonSchemaValidation in the sample demo that was released to the public. Since the name doesn't exist, I'll add it, but I'll get a validation error.
https://codesandbox.io/p/sandbox/json-edit-react-demo-forked-2d6xlx?file=%2Fsrc%2FApp.js%3A9%2C13&workspaceId=ws_CTwx66TnRUb2vkBSHCXygH
The text was updated successfully, but these errors were encountered: