Skip to content

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

@rafaelbeckel

Description

@rafaelbeckel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: done/releasedIssue has been completed, no further action is needed.type: featureIssues related to new features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions