Skip to content

Can we support custom error message for Enumeration Validation? #3825

@dungdq2002

Description

@dungdq2002

Feature request

Since we can validate an Enumeration using sttp.tapir.Validator.Enumeration, I want to have a custom message for the invalid case.

Use case

For example, when we want to validate a list of enumeration inputs, if one of them fails the validation, the error message is too generic to specify which one is wrong.

Proposed solution

We can add an optional field to sttp.tapir.Validator.Enumeration as showMessageOpt: Option[T => String] to handle the error message.

Besides this approach, do we have any workaround? If not, I can help to implement this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions