Skip to content
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

Customizing validation message #201

Open
bperek opened this issue May 31, 2023 · 1 comment
Open

Customizing validation message #201

bperek opened this issue May 31, 2023 · 1 comment

Comments

@bperek
Copy link

bperek commented May 31, 2023

Is there any way to customize the exception message?
In my middleware, I'm validating input and catching ValidationFailure exception. Then, from the previous exception, I'm able to extract f.e. KeywordMismatch exception, get the path to the property that failed, and also return a generic exception message.

It would be helpful to have the option to customize the validation exception message. I found it a bit generic, especially for Enum validation - the generic message is Value must be present in the enum but I want to return also possible values (since spec file is not published yet - it covers only a few endpoints and it is not ready to be published).

I've checked the source code and didn't find any clues on how to achieve that.

Maybe there is a way to get failed property from exception and customize the such message by extracting from Schema by path, method, and breadcrumbs?

@lchhieu
Copy link

lchhieu commented Jun 13, 2023

The same stuck, how can I can overwrite message of Exception such as InvalidQueryArgs, InvalidParameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants