Reputation:
How can i validate Authorization header, and check if it is uuid version 4 or not in nestjs?
I cannot use @Headers(new ParseUUIDPipe()) token: string
.
Upvotes: 2
Views: 3189
Reputation: 70460
Headers are not available to be used with pipes. The reason being is that there could be an unknown number of headers and that possibly lead to a problem with validation. If you need to validate a single header, I'd suggest using either a guard or a n interceptor, depending on if you want to return a BadRequestException
or an UnauthorizedException
Upvotes: 3