fix: extract props from validator issues#3708
Conversation
|
yes the docs update as mentioned makes sense! we should also add an e2e test for this, ideally using multiple standard schema compatible libraries. |
|
View your CI Pipeline Execution ↗ for commit 997261d.
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/create-router
@tanstack/directive-functions-plugin
@tanstack/eslint-plugin-router
@tanstack/create-start
@tanstack/history
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-with-query
@tanstack/react-start
@tanstack/react-start-api-routes
@tanstack/react-start-client
@tanstack/react-start-config
@tanstack/react-start-plugin
@tanstack/react-start-router-manifest
@tanstack/react-start-server
@tanstack/react-start-server-functions-client
@tanstack/react-start-server-functions-fetcher
@tanstack/react-start-server-functions-handler
@tanstack/react-start-server-functions-ssr
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-start
@tanstack/solid-start-api-routes
@tanstack/solid-start-client
@tanstack/solid-start-config
@tanstack/solid-start-plugin
@tanstack/solid-start-router-manifest
@tanstack/solid-start-server
@tanstack/solid-start-server-functions-client
@tanstack/solid-start-server-functions-fetcher
@tanstack/solid-start-server-functions-handler
@tanstack/solid-start-server-functions-ssr
@tanstack/start
@tanstack/start-config
@tanstack/start-server-functions-server
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
|
Thanks for putting this together! I’m closing this PR because it's quite stale, and validation now runs through start-client-core rather than the file changed here. The serialization problem still matters, so I’ve opened #7779 to track a current implementation that covers both server-function and search validation, safe issue normalization, tests, documentation, and bundle-size validation. A fresh PR based on that issue would be welcome :) |
Changes Summary
Replaces naive JSON serialization of validator issues by extracting known properties first, and then serializing extracted values instead of the error itself.
This makes is possible to avoid errors such as validation library having non-serializable errors.
Changes introduced based on the Discord discussion.
How
Introduces utilities provided by Standard Schema to the core package, adds
pathattribute which schema defines, exports the normalization function and uses it within theexecValidator.Result
The validation result is provided under message key in the error response:
{ "$error": { "message": "{\n \"root\": [\n \"must be an object (was a string)\"\n ],\n \"issues\": {}\n}", "stack": "... error stacktrace ...", "cause": { "$undefined": 0 } } }The validation result is split into two parts - root and issues.
rootaggregates all validation messages that happened at the root (as explained in When is Issue.path allowed to be undefined? #60), whileissuescontains all errors for which thepathwas present.Future Work
Docs
Maybe it would be good to reword a docs, to mention that
validatorintegrate seamlessly with external validators, that implement Standard Schema?