feature: include enum values in the error message of IsEnum() decorator
See original GitHub issueDescription
IsEnum(obj) will produce the same error message, regardless of the expected enum values, which is useless for any practical user-facing application. Returning the message “{obj} must be a valid enum value” does not say anything about the expected input and is not actionable (unless there are some supporting docs somewhere else).
Proposed solution
It should behave like IsIn(Object.values(obj)), which returns the message “{obj} must be one of the following values: cupcakes,lollipops,candies,whatever”. This is much nicer and actionable. The end-user cares about the expected values only, not about how they are represented internally.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to set custom error message IsEnum of class-validator in ...
I want to know what value is wrong. If I entered A,B1,C , I would like to receive an error message saying 'The...
Read more >enum — Support for enumerations — Python 3.11.1 ...
The enum members have names and values (the name of Color. ... verify(). Enum class decorator that checks user-selectable constraints on an enumeration....
Read more >Enumerated Types or Enums in C++ - GeeksforGeeks
Enumerated type (enumeration) is a user-defined data type which can be assigned some limited values. These values are defined by the ...
Read more >Build Enumerations of Constants With Python's Enum
Some programming languages, like Java and C++, include syntax that supports a data type known as enumerations, or just enums.
Read more >Java Enum Tutorial: 10 Examples of Enum in Java
The focus of this Java Enum tutorial will be on different features ... Values() method returns an array of Enum constants in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It’s been quite a while, right? 🤔
When is the pull request going to be merged?