Skip to content

Conversation

@SamWooler
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Docs
  • Other... Please describe:

What is the current behavior?

Current docs provide an example of the ZodValidationPipe applied to the entire method using the UsePipes decorator. It is also possible to only apply to the body and allow other pipe validation for example for the route parameters.

What is the new behavior?

Example included for applying ZodValidationPipe only to the request body alongside route paramater validation via ParseIntPipe.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This is good to include as having both a route parameter and a Zod validated request body is a common use case.

Attempting to extend the existing example with a route parameter will apply the ZodValidationPipe to the route parameter. This causes an HTTP 400 request to be returned (the route parameter will be a number not an object and will therefore fail Zod validation).

Screenshot:
Screenshot from 2026-01-07 21-46-20

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

Successfully merging this pull request may close these issues.

2 participants