question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modify JSON Validation for Optgroup support

See original GitHub issue

Hello, I’ve successfully created the widget to support optgroup select (i.e. categories inside a select). I’m now seeking help for the validation.

In order to generate the categories I give a dict instead of a list to my “enum” field. How can I modify the JSON validation to avoid the error .enum should be array

Here is the codepen of my implementation:
https://codepen.io/enola-guy/pen/ZEQOVEN

If you can explain me the steps missing, I would gladly open a PR in order to make this feature in the main branch 😃

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
epicfaacecommented, Jun 14, 2020

@Enola-guy thanks for your custom widget! I don’t think we can merge this into the main library, though, until we have a JSON Schema-compliant approach (and in JSON Schema, enum must be an array, not a dict). Can you think of a JSON-schema-compliant way of using optgroups? For example, this might involve customizing the optgroups in uiSchema using something like this:

{
    "ui:groups": [
         { "title": "Theropods", "items": ["Tyrannosaurus", "Velociraptor"] },
         ...
     ]
}

This is just an idea – let me know if you have any other thoughts / ways of doing this.

0reactions
vladyslavarkavenkocommented, Jul 10, 2020

@Enola-guy Can you please share your working code here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - angular6-json-schema-form issue with multi-select ...
I have created a MaterialSelectComponent file which is a copy of the same file from 'angular6-json-schema-form' and then added the custom ...
Read more >
lamjar - JSON Formatter
JSON Formatter and JSON Validator help to auto format JSON and validate your JSON text. It also provides a tree view that helps...
Read more >
HTML optgroup tag - W3Schools
The <optgroup> tag is used to group related options in a <select> element (drop-down list). If you have a long list of options,...
Read more >
AWS::RDS::OptionGroup - AWS CloudFormation
The AWS::RDS::OptionGroup resource creates or updates an option group, to enable and configure features that are specific to a particular DB engine.
Read more >
Re: Dependencies between two "enums" - Google Groups
And I am still convinced that a mechanism like I proposed would also help jsonary a lot. Also I think the usefulness of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found