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.

Create array of enums

See original GitHub issue

Creating an array of enum doesn’t appear to be implemented, would be nice to have!

var mySchema = new Schema({
  label: [{type:String, enum: ['enumVal1','enumVal2']}]
});

Small snippet of conversation on irc which might give direction:

aheckmann: file an issue, i think its b/c the validation isn't set on the array

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:14

github_iconTop GitHub Comments

3reactions
hankchiutwcommented, Jan 26, 2016

I use something like

roles: { 
    type: [{ type: String, enum: [ 'resident', 'distributor', 'company', 'moderator', 'admin' ] }],
    default: 'resident'
}

to set default value.

1reaction
vkarpov15commented, Mar 10, 2017

@cloud-tribal well the issue is closed with 3.9.6 as the milestone, so I’d imagine that means it was released in 3.9.6. If you’re using 4.x you should be able to access this feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create an array of enums - Stack Overflow
var enums = new Tuple<Enum1, Enum2>(Enum1.Value1, Enum2.AnotherValue); if (enums.Item1 == Enum1.Value1) ... ...but I wouldn ...
Read more >
Convert an Enum to an Array of Objects in TypeScript
Use the Object.keys() method to get an array of the enum's keys. · Filter out the unnecessary values for numeric enums. · Use...
Read more >
TypeScript - Enum to Array - DEV Community ‍ ‍
I'll explain how to do that. Considering a key/value enum, you can use the Object.entries to extract the data and create the array....
Read more >
Enum to Array of Enums VI - NI - National Instruments
array of enums returns an array containing each enum value in order. For example, if enum has values {cat, dog, bird}, array of...
Read more >
Java Arrays and Enums - Marcus Biel
In episode 8 of my free Java Video Course I focus on arrays and enums. ... Let's say we wanted to create an...
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