validate cookies
Describe the feature
just like validating query and body, some endpoints require you to have a certain cookie. like if you request the current signed in user info, you need an access_token cookie. could be named readValidatedCookies or getValidatedCookies with zod, valibot, etc.
Additional information
- [ ] Would you be willing to help implement this feature?
Validation of (JSON) body and (key-value object) query params is based on structured data.
How do you see validating (unstructured string) cookies?
Validation of (JSON) body and (key-value object) query params is based on structured data.
How do you see validating (unstructured string) cookies?
obviously convert the cookies to an object first (parse from cookie-es)
Yes we can do that (although parsing all cookies also costs) but the value part is usually encoded.
Do you have a practical usecase for yourself?
Yes we can do that (although parsing all cookies also costs) but the value part is usually encoded.
Do you have a practical usecase for yourself?
you already parse all cookies from scratch with h3's parseCookies without caching them. i already had a usecase in the original post. this feature is not weird or new, hono and elysia support validating cookies: https://hono.dev/docs/guides/validation https://elysiajs.com/essential/validation#cookie
Thanks for the references, but my question is not answered regarding the practical use case of request cookie validation. If we introduce utility (also for defineValidatedHandler), we need to show a practical example (I'm not against your idea).
For the case of authentication (via cookie), we do have a built-in session utility, and any other custom auth solution, the utility or middleware that handles auth, should already validate cookie values as well itself, so it is probably not the best example.
Thanks for the references, but my question is not answered regarding the practical use case of request cookie validation. If we introduce utility (also for
defineValidatedHandler), we need to show a practical example (I'm not against your idea).For the case of authentication (via cookie), we do have a built-in session utility, and any other custom auth solution, the utility or middleware that handles auth, should already validate cookie values as well itself, so it is probably not the best example.
like storing the user's preferred language 🤔