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

[zod-nestjs]: Implement Custom Exception Class for Zod Validation Failures #209

Open
JunyaIizuka opened this issue Jun 25, 2024 · 4 comments

Comments

@JunyaIizuka
Copy link

I would like to propose the implementation of a dedicated custom exception class for exceptions thrown when Zod validation fails.

Currently, a generic BadRequestException is being thrown, which does not allow us to distinguish whether the failure was due to Zod validation or other causes.
Having a specific custom exception class for Zod validation errors would greatly enhance error handling and debugging processes.

@JunyaIizuka
Copy link
Author

@nicofishman
Copy link

How would it work on this module? The one referenced is deprecated

@philsp
Copy link

philsp commented Oct 8, 2024

It would be nice to have a custom exception class with access to the original values and full parse result.

To detect validation errors in my interceptor, I currently set the errorHttpStatusCode to 418 in the ZodValidationPipe 🫖

@JunyaIizuka
Copy link
Author

I'll try to fix this issue myself in January 2025. Maybe I have free time...

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

3 participants