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.

Enum's title + values

See original GitHub issue

It would be awesome if we could specify enum’s with a title and value attribute. So basically instead of having:

enum: [ "value1", "value2"]

which aren’t saying anything because they are the values, it would be nice if we could specify it like this:

enum: [ {"title": "Foo", "value": "value1"}, {"title": "Bar", "value": "value2"} ]

This way you will get a dropdown or another element where you will see Foo and Bar as selectables but their values underwater would be value1 and value2

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jdorncommented, Aug 31, 2014

I would prefer to not touch the enum property since I want to maintain compatibility with JSON Schema as much as possible. Your proposed syntax would fail to validate since the value is not strictly equal to one of the enumerated objects.

This feature is already implemented using options for the enum editor (used for objects and arrays), but not the select editor (used for strings). I can add this to the select editor too. I’ll also probably merge these two editors in the near future since there’s not much difference between them.

The syntax will be:

{
  "type": "string",
  "enum": ["value1","value2"],
  "options": {
    "enum_titles": ["title1","title2"]
  }
}
0reactions
joseaiocommented, Mar 2, 2016

After view your workaround, not show a single select2 (allowing multiple selections)…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Attaching Values to Java Enum - Baeldung
Java provides a valueOf(String) method for all enum types. Thus, we can always get an enum value based on the declared name: assertSame(Element....
Read more >
Java getting the Enum name given the Enum Value
I am using a lot of nameOf(String name) , now for each I will write a *Enum.values().stream().filter(...).findAny().get() , which is so annoying. –...
Read more >
enum — Support for enumerations — Python 3.11.1 ...
The enum members have names and values (the name of Color. ... Enum class decorator that ensures only one name is bound to...
Read more >
Java.lang.Enum.name() Method - Tutorialspoint
Description. The java.lang.Enum.name() method returns the name of this enum constant, exactly as declared in its enum declaration.
Read more >
Enum (Java Platform SE 7 ) - Oracle Help Center
Returns the name of this enum constant, exactly as declared in its enum declaration. Most programmers should use the toString() method in preference...
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