diff --git a/examples/react/search-validator-adapters/package.json b/examples/react/search-validator-adapters/package.json index d4ae40bdc6..c82feaad0a 100644 --- a/examples/react/search-validator-adapters/package.json +++ b/examples/react/search-validator-adapters/package.json @@ -17,10 +17,10 @@ "@tanstack/router-plugin": "^1.79.0", "@tanstack/router-valibot-adapter": "^1.81.3", "@tanstack/router-zod-adapter": "^1.81.3", - "arktype": "^2.0.0-rc.21", + "arktype": "2.0.0-rc.23", "react": "^18.2.0", "react-dom": "^18.2.0", - "valibot": "1.0.0-beta.3", + "valibot": "1.0.0-beta.5", "zod": "^3.23.8" }, "devDependencies": { diff --git a/packages/react-router/src/route.ts b/packages/react-router/src/route.ts index ed36934ba2..bc4455c7ef 100644 --- a/packages/react-router/src/route.ts +++ b/packages/react-router/src/route.ts @@ -515,9 +515,13 @@ export interface SearchValidatorAdapter { export type AnySearchValidatorAdapter = SearchValidatorAdapter +export interface StandardSchemaValidatorProps { + readonly types?: StandardSchemaValidatorTypes | undefined + readonly validate: AnyStandardSchemaValidate +} + export interface StandardSchemaValidator { - readonly '~types'?: StandardSchemaValidatorTypes | undefined - readonly '~validate': AnyStandardSchemaValidate + readonly '~standard': StandardSchemaValidatorProps } export type AnyStandardSchemaValidator = StandardSchemaValidator @@ -529,6 +533,7 @@ export interface StandardSchemaValidatorTypes { export interface AnyStandardSchemaValidateSuccess { readonly value: any + readonly issues?: undefined } export interface AnyStandardSchemaValidateFailure { @@ -539,13 +544,11 @@ export interface AnyStandardSchemaValidateIssue { readonly message: string } -export interface AnyStandardSchemaValidateInput { - readonly value: any -} - export type AnyStandardSchemaValidate = ( - input: AnyStandardSchemaValidateInput, -) => AnyStandardSchemaValidateSuccess | AnyStandardSchemaValidateFailure + value: unknown, +) => + | (AnyStandardSchemaValidateSuccess | AnyStandardSchemaValidateFailure) + | Promise export type AnySearchValidatorFn = SearchValidatorFn @@ -681,7 +684,7 @@ export type ResolveSearchSchemaFnInput = export type ResolveSearchSchemaInput = TSearchValidator extends AnyStandardSchemaValidator - ? NonNullable['input'] + ? NonNullable['input'] : TSearchValidator extends AnySearchValidatorAdapter ? TSearchValidator['types']['input'] : TSearchValidator extends AnySearchValidatorObj @@ -698,7 +701,7 @@ export type ResolveSearchSchema = unknown extends TSearchValidator ? TSearchValidator : TSearchValidator extends AnyStandardSchemaValidator - ? NonNullable['output'] + ? NonNullable['output'] : TSearchValidator extends AnySearchValidatorAdapter ? TSearchValidator['types']['output'] : TSearchValidator extends AnySearchValidatorObj diff --git a/packages/react-router/src/router.ts b/packages/react-router/src/router.ts index cd58fc7a5d..b5346d0130 100644 --- a/packages/react-router/src/router.ts +++ b/packages/react-router/src/router.ts @@ -585,11 +585,14 @@ function validateSearch( ): unknown { if (validateSearch == null) return {} - if ('~validate' in validateSearch) { - const result = validateSearch['~validate']({ value: input }) + if ('~standard' in validateSearch) { + const result = validateSearch['~standard'].validate(input) if ('value' in result) return result.value + if (result instanceof Promise) + throw new SearchParamError('Async validation not supported') + throw new SearchParamError(JSON.stringify(result.issues, undefined, 2)) } diff --git a/packages/router-valibot-adapter/package.json b/packages/router-valibot-adapter/package.json index 61678af96e..55b20f49ff 100644 --- a/packages/router-valibot-adapter/package.json +++ b/packages/router-valibot-adapter/package.json @@ -67,10 +67,10 @@ "@tanstack/react-router": "workspace:*", "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.0.1", - "valibot": "1.0.0-beta.3" + "valibot": "1.0.0-beta.5" }, "peerDependencies": { "@tanstack/react-router": ">=1.43.2", - "valibot": "^1.0.0 || ^1.0.0-beta || ^1.0.0-rc" + "valibot": "^1.0.0 || ^1.0.0-beta.5 || ^1.0.0-rc" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8d295b8103..b858c7c4f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1781,10 +1781,10 @@ importers: version: 18.3.1 html-webpack-plugin: specifier: ^5.6.3 - version: 5.6.3(@rspack/core@1.0.14(@swc/helpers@0.5.13))(webpack@5.96.1) + version: 5.6.3(@rspack/core@1.0.14(@swc/helpers@0.5.13))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)) swc-loader: specifier: ^0.2.6 - version: 0.2.6(@swc/core@1.8.0(@swc/helpers@0.5.13))(webpack@5.96.1) + version: 0.2.6(@swc/core@1.8.0(@swc/helpers@0.5.13))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)) typescript: specifier: ^5.6.2 version: 5.6.3 @@ -2198,8 +2198,8 @@ importers: specifier: workspace:* version: link:../../../packages/router-zod-adapter arktype: - specifier: ^2.0.0-rc.21 - version: 2.0.0-rc.21 + specifier: 2.0.0-rc.23 + version: 2.0.0-rc.23 react: specifier: ^18.2.0 version: 18.3.1 @@ -2207,8 +2207,8 @@ importers: specifier: ^18.2.0 version: 18.3.1(react@18.3.1) valibot: - specifier: 1.0.0-beta.3 - version: 1.0.0-beta.3(typescript@5.6.3) + specifier: 1.0.0-beta.5 + version: 1.0.0-beta.5(typescript@5.6.3) zod: specifier: ^3.23.8 version: 3.23.8 @@ -2935,7 +2935,7 @@ importers: version: 4.3.3(vite@5.4.10(@types/node@22.8.6)(terser@5.36.0)) html-webpack-plugin: specifier: ^5.6.0 - version: 5.6.3(@rspack/core@1.0.14(@swc/helpers@0.5.13))(webpack@5.96.1) + version: 5.6.3(@rspack/core@1.0.14(@swc/helpers@0.5.13))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)) react: specifier: ^18.3.1 version: 18.3.1 @@ -2944,7 +2944,7 @@ importers: version: 18.3.1(react@18.3.1) swc-loader: specifier: ^0.2.6 - version: 0.2.6(@swc/core@1.8.0(@swc/helpers@0.5.13))(webpack@5.96.1) + version: 0.2.6(@swc/core@1.8.0(@swc/helpers@0.5.13))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)) typescript: specifier: ^5.6.2 version: 5.6.3 @@ -3238,8 +3238,8 @@ importers: specifier: ^16.0.1 version: 16.0.1(@testing-library/dom@10.4.0)(@types/react-dom@18.3.1)(@types/react@18.3.12)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) valibot: - specifier: 1.0.0-beta.3 - version: 1.0.0-beta.3(typescript@5.6.3) + specifier: 1.0.0-beta.5 + version: 1.0.0-beta.5(typescript@5.6.3) packages/router-vite-plugin: dependencies: @@ -3404,9 +3404,15 @@ packages: '@ark/schema@0.21.0': resolution: {integrity: sha512-lYcE2S865F8XNId3Id7SGuVletZVqXs0jtcImX8fPGeSIxzkP43zinrkoeU3SMJB/KJUfhpNxQqBdveCyMOjYQ==} + '@ark/schema@0.23.0': + resolution: {integrity: sha512-406Zx0te3ICd7PkGise4XIxOfmjFzK64tEuiN5rmJDg14AqhySXygMk8QcHqHORDJ7VXhel7J41iduw8eyiFPg==} + '@ark/util@0.21.0': resolution: {integrity: sha512-VeE8OJncWZ1+oKAXp+rNY7IE2AibN/GRWK/ImCqKMC6Z0IHH9LDS/5dtR4C3RvNJw1O9Sur23S93a5HLFkaU1A==} + '@ark/util@0.23.0': + resolution: {integrity: sha512-2mb24N2leQENRh+zPqnlRJzFFf8Xr7BT+/4MJN46/G8C45davpqFfcqvOw0ZlXrjQpBi8H+ZqDQsi95lN/9oVg==} + '@babel/code-frame@7.26.2': resolution: {integrity: sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==} engines: {node: '>=6.9.0'} @@ -6257,6 +6263,9 @@ packages: arktype@2.0.0-rc.21: resolution: {integrity: sha512-XbgxgFsONklbE1alpTQtcV/Foew39zphCXgPzx4g1o+hNMlLgPeNqtcgjC/dBwhyYqEHPlwNIk1vrKO0JFs7yg==} + arktype@2.0.0-rc.23: + resolution: {integrity: sha512-P0e40t3J4rc3xRHzPjzyOK1CgdgKswQJOFBgFLuehSiGcjAuRx6p/9lDVPzXZ62m7q5yRUqFiX8ovN5FjWQjMQ==} + array-each@1.0.1: resolution: {integrity: sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==} engines: {node: '>=0.10.0'} @@ -10303,8 +10312,8 @@ packages: resolution: {integrity: sha512-fcRLaS4H/hrZk9hYwbdRM35D0U8IYMfEClhXxCivOojl+yTRAZH3Zy2sSy6qVCiGbV9YAtPssP6jaChqC9vPCg==} engines: {node: '>= 10.13.0'} - valibot@1.0.0-beta.3: - resolution: {integrity: sha512-PRknKVj2249cF8Pxqil1dahkVHgyaPDq++Y8sA96R5lx4nYnVazs11kefOsRVD3PSygYJG5q2MEdEm7kuSWa+g==} + valibot@1.0.0-beta.5: + resolution: {integrity: sha512-YrU03cSLH8+UIMMAOnYCpD9+c6k/VDlxu13aVDokt/YwtROICC6kkbQeRbamcEuh/+CbFa4pbqOptiNNbHFSog==} peerDependencies: typescript: '>=5' peerDependenciesMeta: @@ -10718,8 +10727,14 @@ snapshots: dependencies: '@ark/util': 0.21.0 + '@ark/schema@0.23.0': + dependencies: + '@ark/util': 0.23.0 + '@ark/util@0.21.0': {} + '@ark/util@0.23.0': {} + '@babel/code-frame@7.26.2': dependencies: '@babel/helper-validator-identifier': 7.25.9 @@ -13311,17 +13326,17 @@ snapshots: '@webassemblyjs/ast': 1.12.1 '@xtuc/long': 4.2.2 - '@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4)(webpack@5.96.1)': + '@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4))': dependencies: webpack: 5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1) - '@webpack-cli/info@2.0.2(webpack-cli@5.1.4)(webpack@5.96.1)': + '@webpack-cli/info@2.0.2(webpack-cli@5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4))': dependencies: webpack: 5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1) - '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4)(webpack-dev-server@5.1.0)(webpack@5.96.1)': + '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1))(webpack-dev-server@5.1.0(webpack-cli@5.1.4)(webpack@5.96.1))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4))': dependencies: webpack: 5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1) @@ -13523,6 +13538,11 @@ snapshots: '@ark/schema': 0.21.0 '@ark/util': 0.21.0 + arktype@2.0.0-rc.23: + dependencies: + '@ark/schema': 0.23.0 + '@ark/util': 0.23.0 + array-each@1.0.1: {} array-flatten@1.1.1: {} @@ -15274,7 +15294,7 @@ snapshots: html-void-elements@3.0.0: {} - html-webpack-plugin@5.6.3(@rspack/core@1.0.14(@swc/helpers@0.5.13))(webpack@5.96.1): + html-webpack-plugin@5.6.3(@rspack/core@1.0.14(@swc/helpers@0.5.13))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)): dependencies: '@types/html-minifier-terser': 6.1.0 html-minifier-terser: 6.1.0 @@ -17415,7 +17435,7 @@ snapshots: csso: 5.0.5 picocolors: 1.1.1 - swc-loader@0.2.6(@swc/core@1.8.0(@swc/helpers@0.5.13))(webpack@5.96.1): + swc-loader@0.2.6(@swc/core@1.8.0(@swc/helpers@0.5.13))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)): dependencies: '@swc/core': 1.8.0(@swc/helpers@0.5.13) '@swc/counter': 0.1.3 @@ -17485,26 +17505,26 @@ snapshots: mkdirp: 1.0.4 yallist: 4.0.0 - terser-webpack-plugin@5.3.10(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)): + terser-webpack-plugin@5.3.10(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.36.0 - webpack: 5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0) + webpack: 5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4) optionalDependencies: '@swc/core': 1.8.0(@swc/helpers@0.5.13) esbuild: 0.24.0 - terser-webpack-plugin@5.3.10(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack@5.96.1): + terser-webpack-plugin@5.3.10(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.36.0 - webpack: 5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4) + webpack: 5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0) optionalDependencies: '@swc/core': 1.8.0(@swc/helpers@0.5.13) esbuild: 0.24.0 @@ -17915,7 +17935,7 @@ snapshots: v8flags@4.0.1: {} - valibot@1.0.0-beta.3(typescript@5.6.3): + valibot@1.0.0-beta.5(typescript@5.6.3): optionalDependencies: typescript: 5.6.3 @@ -18161,9 +18181,9 @@ snapshots: webpack-cli@5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1): dependencies: '@discoveryjs/json-ext': 0.5.7 - '@webpack-cli/configtest': 2.1.1(webpack-cli@5.1.4)(webpack@5.96.1) - '@webpack-cli/info': 2.0.2(webpack-cli@5.1.4)(webpack@5.96.1) - '@webpack-cli/serve': 2.0.5(webpack-cli@5.1.4)(webpack-dev-server@5.1.0)(webpack@5.96.1) + '@webpack-cli/configtest': 2.1.1(webpack-cli@5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)) + '@webpack-cli/info': 2.0.2(webpack-cli@5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)) + '@webpack-cli/serve': 2.0.5(webpack-cli@5.1.4(webpack-dev-server@5.1.0)(webpack@5.96.1))(webpack-dev-server@5.1.0(webpack-cli@5.1.4)(webpack@5.96.1))(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)) colorette: 2.0.20 commander: 10.0.1 cross-spawn: 7.0.3 @@ -18177,7 +18197,7 @@ snapshots: optionalDependencies: webpack-dev-server: 5.1.0(webpack-cli@5.1.4)(webpack@5.96.1) - webpack-dev-middleware@7.4.2(webpack@5.96.1): + webpack-dev-middleware@7.4.2(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)): dependencies: colorette: 2.0.20 memfs: 4.14.0 @@ -18216,7 +18236,7 @@ snapshots: serve-index: 1.9.1 sockjs: 0.3.24 spdy: 4.0.2 - webpack-dev-middleware: 7.4.2(webpack@5.96.1) + webpack-dev-middleware: 7.4.2(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)) ws: 8.18.0 optionalDependencies: webpack: 5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4) @@ -18289,7 +18309,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack@5.96.1) + terser-webpack-plugin: 5.3.10(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack@5.96.1(@swc/core@1.8.0(@swc/helpers@0.5.13))(esbuild@0.24.0)(webpack-cli@5.1.4)) watchpack: 2.4.2 webpack-sources: 3.2.3 optionalDependencies: