@tanstack/zod-adapter 1.121.16 → 1.121.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/dist/cjs/index.cjs +0 -22
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -18
- package/dist/esm/index.d.ts +0 -18
- package/dist/esm/index.js +0 -22
- package/dist/esm/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/zod-adapter",
|
|
3
|
-
"version": "1.121.
|
|
3
|
+
"version": "1.121.18",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"zod": "^3.24.2",
|
|
55
55
|
"react": "^19.0.0",
|
|
56
56
|
"react-dom": "^19.0.0",
|
|
57
|
-
"@tanstack/react-router": "^1.121.
|
|
57
|
+
"@tanstack/react-router": "^1.121.18"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"zod": "^3.23.8",
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const zod = require("zod");
|
|
4
|
-
const zodValidator = (options) => {
|
|
5
|
-
const input = "input" in options ? options.input : "input";
|
|
6
|
-
const output = "output" in options ? options.output : "output";
|
|
7
|
-
const _input = "schema" in options ? options.schema._input : options._input;
|
|
8
|
-
const _output = "schema" in options ? options.schema._output : options._output;
|
|
9
|
-
return {
|
|
10
|
-
types: {
|
|
11
|
-
input: input === "output" ? _output : _input,
|
|
12
|
-
output: output === "input" ? _input : _output
|
|
13
|
-
},
|
|
14
|
-
parse: (input2) => "schema" in options ? options.schema.parse(input2) : options.parse(input2)
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
const fallback = (schema, fallback2) => {
|
|
18
|
-
return zod.z.custom().pipe(schema.catch(fallback2));
|
|
19
|
-
};
|
|
20
|
-
exports.fallback = fallback;
|
|
21
|
-
exports.zodValidator = zodValidator;
|
|
22
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import { z } from 'zod'\nimport type { ValidatorAdapter } from '@tanstack/react-router'\n\nexport interface ZodTypeLike {\n _input: any\n _output: any\n parse: (input: any) => any\n}\n\nexport type InputOutputOption = 'input' | 'output'\n\nexport interface zodValidatorOptions {\n readonly schema: ZodTypeLike\n readonly input?: InputOutputOption\n readonly output?: InputOutputOption\n}\n\nexport type zodValidatorInput<\n TOptions extends ZodTypeLike | zodValidatorOptions,\n> = TOptions extends zodValidatorOptions\n ? 'input' extends TOptions['input']\n ? TOptions['schema']['_input']\n : TOptions['schema']['_output']\n : TOptions extends ZodTypeLike\n ? TOptions['_input']\n : never\n\nexport type zodValidatorOutput<\n TOptions extends ZodTypeLike | zodValidatorOptions,\n> = TOptions extends zodValidatorOptions\n ? 'output' extends TOptions['output']\n ? TOptions['schema']['_output']\n : TOptions['schema']['_input']\n : TOptions extends ZodTypeLike\n ? TOptions['_output']\n : never\n\nexport type zodValidatorAdapter<\n TOptions extends ZodTypeLike | zodValidatorOptions,\n> = ValidatorAdapter<zodValidatorInput<TOptions>, zodValidatorOutput<TOptions>>\n\nexport const zodValidator = <\n TOptions extends ZodTypeLike | zodValidatorOptions,\n>(\n options: TOptions,\n): zodValidatorAdapter<TOptions> => {\n const input = 'input' in options ? options.input : 'input'\n const output = 'output' in options ? options.output : 'output'\n const _input = 'schema' in options ? options.schema._input : options._input\n const _output = 'schema' in options ? options.schema._output : options._output\n return {\n types: {\n input: input === 'output' ? _output : _input,\n output: output === 'input' ? _input : _output,\n },\n parse: (input) =>\n 'schema' in options ? options.schema.parse(input) : options.parse(input),\n }\n}\n\nexport const fallback = <TSchema extends z.ZodTypeAny>(\n schema: TSchema,\n fallback: TSchema['_input'],\n): z.ZodPipeline<\n z.ZodType<TSchema['_input'], z.ZodTypeDef, TSchema['_input']>,\n z.ZodCatch<TSchema>\n> => {\n return z.custom<TSchema['_input']>().pipe(schema.catch(fallback))\n}\n"],"names":["input","fallback","z"],"mappings":";;;AAyCa,MAAA,eAAe,CAG1B,YACkC;AAClC,QAAM,QAAQ,WAAW,UAAU,QAAQ,QAAQ;AACnD,QAAM,SAAS,YAAY,UAAU,QAAQ,SAAS;AACtD,QAAM,SAAS,YAAY,UAAU,QAAQ,OAAO,SAAS,QAAQ;AACrE,QAAM,UAAU,YAAY,UAAU,QAAQ,OAAO,UAAU,QAAQ;AAChE,SAAA;AAAA,IACL,OAAO;AAAA,MACL,OAAO,UAAU,WAAW,UAAU;AAAA,MACtC,QAAQ,WAAW,UAAU,SAAS;AAAA,IACxC;AAAA,IACA,OAAO,CAACA,WACN,YAAY,UAAU,QAAQ,OAAO,MAAMA,MAAK,IAAI,QAAQ,MAAMA,MAAK;AAAA,EAC3E;AACF;AAEa,MAAA,WAAW,CACtB,QACAC,cAIG;AACH,SAAOC,IAAAA,EAAE,SAA4B,KAAK,OAAO,MAAMD,SAAQ,CAAC;AAClE;;;"}
|
package/dist/cjs/index.d.cts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ValidatorAdapter } from '@tanstack/react-router';
|
|
3
|
-
export interface ZodTypeLike {
|
|
4
|
-
_input: any;
|
|
5
|
-
_output: any;
|
|
6
|
-
parse: (input: any) => any;
|
|
7
|
-
}
|
|
8
|
-
export type InputOutputOption = 'input' | 'output';
|
|
9
|
-
export interface zodValidatorOptions {
|
|
10
|
-
readonly schema: ZodTypeLike;
|
|
11
|
-
readonly input?: InputOutputOption;
|
|
12
|
-
readonly output?: InputOutputOption;
|
|
13
|
-
}
|
|
14
|
-
export type zodValidatorInput<TOptions extends ZodTypeLike | zodValidatorOptions> = TOptions extends zodValidatorOptions ? 'input' extends TOptions['input'] ? TOptions['schema']['_input'] : TOptions['schema']['_output'] : TOptions extends ZodTypeLike ? TOptions['_input'] : never;
|
|
15
|
-
export type zodValidatorOutput<TOptions extends ZodTypeLike | zodValidatorOptions> = TOptions extends zodValidatorOptions ? 'output' extends TOptions['output'] ? TOptions['schema']['_output'] : TOptions['schema']['_input'] : TOptions extends ZodTypeLike ? TOptions['_output'] : never;
|
|
16
|
-
export type zodValidatorAdapter<TOptions extends ZodTypeLike | zodValidatorOptions> = ValidatorAdapter<zodValidatorInput<TOptions>, zodValidatorOutput<TOptions>>;
|
|
17
|
-
export declare const zodValidator: <TOptions extends ZodTypeLike | zodValidatorOptions>(options: TOptions) => zodValidatorAdapter<TOptions>;
|
|
18
|
-
export declare const fallback: <TSchema extends z.ZodTypeAny>(schema: TSchema, fallback: TSchema["_input"]) => z.ZodPipeline<z.ZodType<TSchema["_input"], z.ZodTypeDef, TSchema["_input"]>, z.ZodCatch<TSchema>>;
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ValidatorAdapter } from '@tanstack/react-router';
|
|
3
|
-
export interface ZodTypeLike {
|
|
4
|
-
_input: any;
|
|
5
|
-
_output: any;
|
|
6
|
-
parse: (input: any) => any;
|
|
7
|
-
}
|
|
8
|
-
export type InputOutputOption = 'input' | 'output';
|
|
9
|
-
export interface zodValidatorOptions {
|
|
10
|
-
readonly schema: ZodTypeLike;
|
|
11
|
-
readonly input?: InputOutputOption;
|
|
12
|
-
readonly output?: InputOutputOption;
|
|
13
|
-
}
|
|
14
|
-
export type zodValidatorInput<TOptions extends ZodTypeLike | zodValidatorOptions> = TOptions extends zodValidatorOptions ? 'input' extends TOptions['input'] ? TOptions['schema']['_input'] : TOptions['schema']['_output'] : TOptions extends ZodTypeLike ? TOptions['_input'] : never;
|
|
15
|
-
export type zodValidatorOutput<TOptions extends ZodTypeLike | zodValidatorOptions> = TOptions extends zodValidatorOptions ? 'output' extends TOptions['output'] ? TOptions['schema']['_output'] : TOptions['schema']['_input'] : TOptions extends ZodTypeLike ? TOptions['_output'] : never;
|
|
16
|
-
export type zodValidatorAdapter<TOptions extends ZodTypeLike | zodValidatorOptions> = ValidatorAdapter<zodValidatorInput<TOptions>, zodValidatorOutput<TOptions>>;
|
|
17
|
-
export declare const zodValidator: <TOptions extends ZodTypeLike | zodValidatorOptions>(options: TOptions) => zodValidatorAdapter<TOptions>;
|
|
18
|
-
export declare const fallback: <TSchema extends z.ZodTypeAny>(schema: TSchema, fallback: TSchema["_input"]) => z.ZodPipeline<z.ZodType<TSchema["_input"], z.ZodTypeDef, TSchema["_input"]>, z.ZodCatch<TSchema>>;
|
package/dist/esm/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
const zodValidator = (options) => {
|
|
3
|
-
const input = "input" in options ? options.input : "input";
|
|
4
|
-
const output = "output" in options ? options.output : "output";
|
|
5
|
-
const _input = "schema" in options ? options.schema._input : options._input;
|
|
6
|
-
const _output = "schema" in options ? options.schema._output : options._output;
|
|
7
|
-
return {
|
|
8
|
-
types: {
|
|
9
|
-
input: input === "output" ? _output : _input,
|
|
10
|
-
output: output === "input" ? _input : _output
|
|
11
|
-
},
|
|
12
|
-
parse: (input2) => "schema" in options ? options.schema.parse(input2) : options.parse(input2)
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
const fallback = (schema, fallback2) => {
|
|
16
|
-
return z.custom().pipe(schema.catch(fallback2));
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
fallback,
|
|
20
|
-
zodValidator
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { z } from 'zod'\nimport type { ValidatorAdapter } from '@tanstack/react-router'\n\nexport interface ZodTypeLike {\n _input: any\n _output: any\n parse: (input: any) => any\n}\n\nexport type InputOutputOption = 'input' | 'output'\n\nexport interface zodValidatorOptions {\n readonly schema: ZodTypeLike\n readonly input?: InputOutputOption\n readonly output?: InputOutputOption\n}\n\nexport type zodValidatorInput<\n TOptions extends ZodTypeLike | zodValidatorOptions,\n> = TOptions extends zodValidatorOptions\n ? 'input' extends TOptions['input']\n ? TOptions['schema']['_input']\n : TOptions['schema']['_output']\n : TOptions extends ZodTypeLike\n ? TOptions['_input']\n : never\n\nexport type zodValidatorOutput<\n TOptions extends ZodTypeLike | zodValidatorOptions,\n> = TOptions extends zodValidatorOptions\n ? 'output' extends TOptions['output']\n ? TOptions['schema']['_output']\n : TOptions['schema']['_input']\n : TOptions extends ZodTypeLike\n ? TOptions['_output']\n : never\n\nexport type zodValidatorAdapter<\n TOptions extends ZodTypeLike | zodValidatorOptions,\n> = ValidatorAdapter<zodValidatorInput<TOptions>, zodValidatorOutput<TOptions>>\n\nexport const zodValidator = <\n TOptions extends ZodTypeLike | zodValidatorOptions,\n>(\n options: TOptions,\n): zodValidatorAdapter<TOptions> => {\n const input = 'input' in options ? options.input : 'input'\n const output = 'output' in options ? options.output : 'output'\n const _input = 'schema' in options ? options.schema._input : options._input\n const _output = 'schema' in options ? options.schema._output : options._output\n return {\n types: {\n input: input === 'output' ? _output : _input,\n output: output === 'input' ? _input : _output,\n },\n parse: (input) =>\n 'schema' in options ? options.schema.parse(input) : options.parse(input),\n }\n}\n\nexport const fallback = <TSchema extends z.ZodTypeAny>(\n schema: TSchema,\n fallback: TSchema['_input'],\n): z.ZodPipeline<\n z.ZodType<TSchema['_input'], z.ZodTypeDef, TSchema['_input']>,\n z.ZodCatch<TSchema>\n> => {\n return z.custom<TSchema['_input']>().pipe(schema.catch(fallback))\n}\n"],"names":["input","fallback"],"mappings":";AAyCa,MAAA,eAAe,CAG1B,YACkC;AAClC,QAAM,QAAQ,WAAW,UAAU,QAAQ,QAAQ;AACnD,QAAM,SAAS,YAAY,UAAU,QAAQ,SAAS;AACtD,QAAM,SAAS,YAAY,UAAU,QAAQ,OAAO,SAAS,QAAQ;AACrE,QAAM,UAAU,YAAY,UAAU,QAAQ,OAAO,UAAU,QAAQ;AAChE,SAAA;AAAA,IACL,OAAO;AAAA,MACL,OAAO,UAAU,WAAW,UAAU;AAAA,MACtC,QAAQ,WAAW,UAAU,SAAS;AAAA,IACxC;AAAA,IACA,OAAO,CAACA,WACN,YAAY,UAAU,QAAQ,OAAO,MAAMA,MAAK,IAAI,QAAQ,MAAMA,MAAK;AAAA,EAC3E;AACF;AAEa,MAAA,WAAW,CACtB,QACAC,cAIG;AACH,SAAO,EAAE,SAA4B,KAAK,OAAO,MAAMA,SAAQ,CAAC;AAClE;"}
|