Skip to content

Route validateSearch appears to validate the "output" of the validation after subsequent updates with useNavigate #6460

@NBruhno

Description

@NBruhno

Which project does this relate to?

Router

Describe the bug

Hello 👋

I've encountered an issue with the latest version I've tested (v1.154.12) and it appears that the issue was introduced in v1.153.2, where the output of the validation gets validated by subsequent changes to the search params, but not on initial load.

Let me know if you need anything else from me or if this is expected to be an unsupported use-case going forward and in that case I'm sorry 😅.

Your Example Website or App

https://stackblitz.com/edit/github-q4r4cqao?file=src%2Froutes%2Findex.tsx

Steps to Reproduce the Bug or Issue

  1. Open up the repro
  2. Press the button to update the query
  3. Should now show an error claiming it received a number but a string was set
[
  {
    "data": 0,
    "path": [
      "test-param"
    ],
    "code": "domain",
    "description": "a string",
    "meta": {},
    "domain": "string",
    "expected": "a string",
    "actual": "a number",
    "problem": "must be a string (was a number)",
    "message": "value at [\"test-param\"] must be a string (was a number)"
  }
]

Expected behavior

Versions prior to 1.153.2 allowed piping input to a differently typed output without causing issues on subsequent updates to the path

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.154.12
  • OS: Linux
  • Browser: Chrome
  • Browser Version: 144.0.7559.97
  • Bundler: vite
  • Bundler Version: 7.3.1

Additional context

No response

Edit

I've updated the example to include one for a date since someone left a comment on the issue that I cannot see anymore saying that it is expected because the router parses the values to JSON internally e.g. number parsing. This might be the case, but it also breaks for situations where I wouldn't expect it to try to pass it around as JSON, e.g. when piping it to classes such as Temporal for date handling, especially when I am not giving it a Temporal class, that is only given by the validator after it has parsed the string.

They also mentioned that the validation did not fail initially because the params are optional. This is also not correct since appending ?month-param=2026-01 to the preview URL and setting the param as required does not fail on load.

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