TanStackT
TanStack12mo ago
6 replies
efficient-indigo

What's the best way to validate path params?

Let's say I had the route:
'/read/$language'

And I wanted to validate that the $language path param was of a certain type (like type Language = "English" | "Spanish" ) or throw/fallback/redirect.

How could I do that?

Server functions, middleware, and even search params have validators.

Maybe we could add validation of path params as well?

Perhaps there was a decision to not add path param validation... If so, maybe someone could let me know why.

Thanks!
Was this page helpful?