Skip to content

Allow replace method to bypass param validation? #139

@enguerranws

Description

@enguerranws

Hi,

I'm wondering if there's any passthrough feature (like zod does)?

My use case is that we want to using tracking params on routes, but on some routes we have forms that are updating URL query params (using type-route replace() method), and are initially populated with query params values (so the user can share the url).

So, I'm taking original params in the URL, I'm merging them with my form key/values and give it all to the replace() method, which throws an error.

To make it work, I simply added the tracking params key to my route definitions, but I'll may have to change that if we need another tracking tool or whatever.

Is there a way to make type-route more compliant, so we could do something like:

userList: defineRoute(
    {
      page: param.query.optional.number,
    },
    () => "/user",
    {
      passthrough: true
    }
  )
 
 // then I could do
 
 routes.userList({page: 2, my_unknown_param: "whatever"}).replace() // without throwing an error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions