Skip to content

Numeric strings in search params issue #537

@vixducis

Description

@vixducis

Describe the bug

Consider the following scenario:

  • You have a route where you accept a string as a search param. (validate it with zod)
  • Pass a numeric string as a search param through the route. (e.g. navigate({search: {test: '3'}))
  • You'll see that an error is thrown, this is because the router will receive the query param as a number, and the zod validator will consider it illegal as it is not a string

Your Example Website or App

https://stackblitz.com/edit/github-fbut9a-bu53ju?file=src/IndexComponent.tsx

Steps to Reproduce the Bug or Issue

  • Open the stackblitz
  • Click on the Set test param to 3 // should fail button.
  • An error will be thrown

Expected behavior

I would hope the search param could be considered a string. I don't know if the casting could be done based on the validation?

Screenshots or Videos

No response

Platform

  • OS: Windows
  • Browser: Firefox
    • Version: 110

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions