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.

feature: include enum values in the error message of IsEnum() decorator

See original GitHub issue

Description

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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
hoodcommented, Apr 14, 2022

Feature implemented in #887. Waiting for review and approval.

When is the pull request going to be merged?

It’s been quite a while, right? 🤔

1reaction
rpihlakcommented, Apr 14, 2022

Feature implemented in #887. Waiting for review and approval.

When is the pull request going to be merged?

Read more comments on GitHub >

github_iconTop 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 >

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