-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
New type: ENUM #1321
Comments
Instead of introducing a new type, I would prefer to add a
It's similar as https://github.com/hapijs/joi#anyvalidvalue---aliases-only-equal |
Sounds good 👍 |
+1 |
FWIW, we already have ENUM validation implemented via I guess we only need to map |
+1 Would these additions then translate to loopback explorer? It'd be nice to show the allowed values. |
+1 |
7 similar comments
👍 |
👍 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
The benefit of making this a type instead of a loopback option is that if you need to provision for a secondary access method which isn't via loopback then the enum won't validate the input. Obviously not every use case by far but worth keeping in mind. |
+1 Enums are a common pattern; adding enum support - whether as a type or a constraint - would greatly simplify repeated validity checks on parameters. |
+1 |
1 similar comment
+1 |
👍 |
1 similar comment
+1 |
+1 |
I have a solution and I'm using it in my project:
In game.js file:
|
+100000000 |
+1 |
Feature development on loopback@3.x is winding down as a result of our push towards loopback-next. Given the nature of the new framework and its use of TypeScript, support for things like enums will be much easier to implement going forward rather than on this current version. |
Does it mean that loopback-next is around the corner and there is a clear migration path? |
Loopback-next is going into beta soon and will consist of the most core components of the framework. The intention of the new platform is to focus more of our energy on providing a solid foundation, rather than attempting to build every connector and component for everyone. Migration However, there won't necessarily be a direct upgrade path for your application that transforms your existing logic into a loopback@4.x compatible application. I'd strongly encourage reading the wiki (https://github.com/strongloop/loopback-next/wiki); it's still a work-in-progress but combining it with the loopback-next-example repo should give you insight into loopback-next's many potential workflows and designs. |
@terehov Sorry, forgot to add your name to the comment. :P |
@kjdelisle Where should I look for enum related model data validations in Loopback 4? |
Let's move the discussion to loopbackio/loopback-next#3033. |
For anybody who lands in this issue: if ENUMs are important to you, then please up-vote loopbackio/loopback-next#3033 by adding a 👍 reaction at the top. Please DO NOT post +1 comments, those are not helpful. |
Implement a new property type - enum (enumeration).
Example model definition:
Example remoting argument definition:
Implementation details:
The text was updated successfully, but these errors were encountered: