@hookform/resolvers 5.0.0 → 5.1.0
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/README.md +17 -16
- package/ajv/package.json +1 -1
- package/arktype/package.json +1 -1
- package/computed-types/package.json +1 -1
- package/effect-ts/package.json +1 -1
- package/fluentvalidation-ts/package.json +1 -1
- package/io-ts/package.json +1 -1
- package/joi/package.json +1 -1
- package/nope/package.json +1 -1
- package/package.json +3 -3
- package/standard-schema/package.json +1 -1
- package/standard-schema/src/__tests__/__fixtures__/data.ts +1 -1
- package/standard-schema/src/__tests__/standard-schema.ts +1 -1
- package/superstruct/package.json +1 -1
- package/typanion/package.json +1 -1
- package/typebox/package.json +1 -1
- package/typebox/src/__tests__/typebox.ts +2 -2
- package/typeschema/dist/typeschema.d.ts +1 -1
- package/typeschema/dist/typeschema.js.map +1 -1
- package/typeschema/dist/typeschema.modern.mjs.map +1 -1
- package/typeschema/dist/typeschema.module.js.map +1 -1
- package/typeschema/dist/typeschema.umd.js.map +1 -1
- package/typeschema/package.json +1 -1
- package/typeschema/src/__tests__/Form-native-validation.tsx +1 -1
- package/typeschema/src/__tests__/Form.tsx +1 -1
- package/typeschema/src/__tests__/__fixtures__/data.ts +1 -1
- package/typeschema/src/__tests__/typeschema.ts +1 -1
- package/typeschema/src/typeschema.ts +1 -1
- package/valibot/package.json +1 -1
- package/vest/package.json +1 -1
- package/vine/package.json +1 -1
- package/yup/package.json +1 -1
- package/zod/dist/zod.d.ts +46 -7
- package/zod/dist/zod.js +1 -1
- package/zod/dist/zod.js.map +1 -1
- package/zod/dist/zod.mjs +1 -1
- package/zod/dist/zod.modern.mjs +1 -1
- package/zod/dist/zod.modern.mjs.map +1 -1
- package/zod/dist/zod.module.js +1 -1
- package/zod/dist/zod.module.js.map +1 -1
- package/zod/dist/zod.umd.js +1 -1
- package/zod/dist/zod.umd.js.map +1 -1
- package/zod/package.json +1 -1
- package/zod/src/__tests__/Form-native-validation.tsx +1 -1
- package/zod/src/__tests__/Form.tsx +1 -1
- package/zod/src/__tests__/__fixtures__/{data.ts → data-v3.ts} +1 -1
- package/zod/src/__tests__/__fixtures__/data-v4-mini.ts +98 -0
- package/zod/src/__tests__/__fixtures__/data-v4.ts +89 -0
- package/zod/src/__tests__/zod-v3.ts +178 -0
- package/zod/src/__tests__/zod-v4-mini.ts +182 -0
- package/zod/src/__tests__/{zod.ts → zod-v4.ts} +17 -2
- package/zod/src/zod.ts +227 -53
package/README.md
CHANGED
|
@@ -34,25 +34,25 @@ Install your preferred validation library alongside `@hookform/resolvers`.
|
|
|
34
34
|
|
|
35
35
|
| resolver | Infer values <br /> from schema | [criteriaMode](https://react-hook-form.com/docs/useform#criteriaMode) |
|
|
36
36
|
|---|---|---|
|
|
37
|
-
| AJV | ❌ | `firstError
|
|
37
|
+
| AJV | ❌ | `firstError \| all` |
|
|
38
38
|
| Arktype | ✅ | `firstError` |
|
|
39
|
-
| class-validator | ✅ | `firstError
|
|
39
|
+
| class-validator | ✅ | `firstError \| all` |
|
|
40
40
|
| computed-types | ✅ | `firstError` |
|
|
41
|
-
| Effect | ✅ | `firstError
|
|
41
|
+
| Effect | ✅ | `firstError \| all` |
|
|
42
42
|
| fluentvalidation-ts | ❌ | `firstError` |
|
|
43
43
|
| io-ts | ✅ | `firstError` |
|
|
44
|
-
| joi | ❌ | `firstError
|
|
44
|
+
| joi | ❌ | `firstError \| all` |
|
|
45
45
|
| Nope | ❌ | `firstError` |
|
|
46
|
-
| Standard Schema | ✅ | `firstError
|
|
46
|
+
| Standard Schema | ✅ | `firstError \| all` |
|
|
47
47
|
| Superstruct | ✅ | `firstError` |
|
|
48
48
|
| typanion | ✅ | `firstError` |
|
|
49
|
-
| typebox | ✅ | `firstError
|
|
50
|
-
| typeschema | ❌ | `firstError
|
|
51
|
-
| valibot | ✅ | `firstError
|
|
52
|
-
| vest | ❌ | `firstError
|
|
53
|
-
| vine | ✅ | `firstError
|
|
54
|
-
| yup | ✅ | `firstError
|
|
55
|
-
| zod | ✅ | `firstError
|
|
49
|
+
| typebox | ✅ | `firstError \| all` |
|
|
50
|
+
| typeschema | ❌ | `firstError \| all` |
|
|
51
|
+
| valibot | ✅ | `firstError \| all` |
|
|
52
|
+
| vest | ❌ | `firstError \| all` |
|
|
53
|
+
| vine | ✅ | `firstError \| all` |
|
|
54
|
+
| yup | ✅ | `firstError \| all` |
|
|
55
|
+
| zod | ✅ | `firstError \| all` |
|
|
56
56
|
</details>
|
|
57
57
|
|
|
58
58
|
## TypeScript
|
|
@@ -68,7 +68,7 @@ Example:
|
|
|
68
68
|
```tsx
|
|
69
69
|
import { useForm } from 'react-hook-form';
|
|
70
70
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
71
|
-
import { z } from 'zod';
|
|
71
|
+
import { z } from 'zod'; // or 'zod/v4'
|
|
72
72
|
|
|
73
73
|
const schema = z.object({
|
|
74
74
|
id: z.number(),
|
|
@@ -91,7 +91,9 @@ useForm<z.input<typeof schema>, any, z.output<typeof schema>>({
|
|
|
91
91
|
|
|
92
92
|
### Supported resolvers
|
|
93
93
|
|
|
94
|
+
- [React Hook Form Resolvers](#react-hook-form-resolvers)
|
|
94
95
|
- [Install](#install)
|
|
96
|
+
- [TypeScript](#typescript)
|
|
95
97
|
- [Links](#links)
|
|
96
98
|
- [Supported resolvers](#supported-resolvers)
|
|
97
99
|
- [API](#api)
|
|
@@ -118,7 +120,6 @@ useForm<z.input<typeof schema>, any, z.output<typeof schema>>({
|
|
|
118
120
|
- [fluentvalidation-ts](#fluentvalidation-ts)
|
|
119
121
|
- [standard-schema](#standard-schema)
|
|
120
122
|
- [Backers](#backers)
|
|
121
|
-
- [Sponsors](#sponsors)
|
|
122
123
|
- [Contributors](#contributors)
|
|
123
124
|
|
|
124
125
|
## API
|
|
@@ -174,7 +175,7 @@ const App = () => {
|
|
|
174
175
|
};
|
|
175
176
|
```
|
|
176
177
|
|
|
177
|
-
### [Zod](https://github.com/
|
|
178
|
+
### [Zod](https://github.com/colinhacks/zod)
|
|
178
179
|
|
|
179
180
|
TypeScript-first schema validation with static type inference
|
|
180
181
|
|
|
@@ -185,7 +186,7 @@ TypeScript-first schema validation with static type inference
|
|
|
185
186
|
```tsx
|
|
186
187
|
import { useForm } from 'react-hook-form';
|
|
187
188
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
188
|
-
import { z } from 'zod';
|
|
189
|
+
import { z } from 'zod'; // or 'zod/v4'
|
|
189
190
|
|
|
190
191
|
const schema = z.object({
|
|
191
192
|
name: z.string().min(1, { message: 'Required' }),
|
package/ajv/package.json
CHANGED
package/arktype/package.json
CHANGED
package/effect-ts/package.json
CHANGED
package/io-ts/package.json
CHANGED
package/joi/package.json
CHANGED
package/nope/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hookform/resolvers",
|
|
3
3
|
"amdName": "hookformResolvers",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.1.0",
|
|
5
5
|
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types, TypeBox, arktype, Typanion, Effect-TS and VineJS",
|
|
6
6
|
"main": "dist/resolvers.js",
|
|
7
7
|
"module": "dist/resolvers.module.js",
|
|
@@ -314,10 +314,10 @@
|
|
|
314
314
|
"vite-tsconfig-paths": "^5.1.4",
|
|
315
315
|
"vitest": "^3.0.9",
|
|
316
316
|
"yup": "^1.6.1",
|
|
317
|
-
"zod": "^3.
|
|
317
|
+
"zod": "^3.25.0"
|
|
318
318
|
},
|
|
319
319
|
"peerDependencies": {
|
|
320
|
-
"react-hook-form": "7.55.0"
|
|
320
|
+
"react-hook-form": "^7.55.0"
|
|
321
321
|
},
|
|
322
322
|
"dependencies": {
|
|
323
323
|
"@standard-schema/utils": "^0.3.0"
|
package/superstruct/package.json
CHANGED
package/typanion/package.json
CHANGED
package/typebox/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Type } from '@sinclair/typebox';
|
|
2
|
+
import { TypeCompiler } from '@sinclair/typebox/compiler';
|
|
1
3
|
import { Resolver, SubmitHandler, useForm } from 'react-hook-form';
|
|
2
4
|
import { typeboxResolver } from '..';
|
|
3
5
|
import { fields, invalidData, schema, validData } from './__fixtures__/data';
|
|
4
|
-
import { Type } from '@sinclair/typebox';
|
|
5
|
-
import { TypeCompiler } from '@sinclair/typebox/compiler';
|
|
6
6
|
|
|
7
7
|
const shouldUseNativeValidation = false;
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
2
|
import { FieldValues, Resolver } from 'react-hook-form';
|
|
2
|
-
import { StandardSchemaV1 } from 'zod/lib/standard-schema';
|
|
3
3
|
export declare function typeschemaResolver<Input extends FieldValues, Context, Output>(schema: StandardSchemaV1<Input, Output>, _schemaOptions?: never, resolverOptions?: {
|
|
4
4
|
raw?: false;
|
|
5
5
|
}): Resolver<Input, Context, Output>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeschema.js","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\
|
|
1
|
+
{"version":3,"file":"typeschema.js","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nconst parseErrorSchema = (\n typeschemaErrors: readonly StandardSchemaV1.Issue[],\n validateAllFieldCriteria: boolean,\n): FieldErrors => {\n const schemaErrors = Object.assign([], typeschemaErrors);\n const errors: Record<string, FieldError> = {};\n\n for (; schemaErrors.length; ) {\n const error = typeschemaErrors[0];\n\n if (!error.path) {\n continue;\n }\n const _path = error.path.join('.');\n\n if (!errors[_path]) {\n errors[_path] = { message: error.message, type: '' };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[''];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '',\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n schemaErrors.shift();\n }\n\n return errors;\n};\n\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions?: never,\n resolverOptions?: {\n raw?: false;\n },\n): Resolver<Input, Context, Output>;\n\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions: never | undefined,\n resolverOptions: {\n raw: true;\n },\n): Resolver<Input, Context, Input>;\n\n/**\n * Creates a resolver for react-hook-form using TypeSchema validation\n * @param {any} schema - The TypeSchema to validate against\n * @param {any} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = z.object({\n * name: z.string().required(),\n * age: z.number().required(),\n * });\n *\n * useForm({\n * resolver: typeschemaResolver(schema)\n * });\n */\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions?: never,\n resolverOptions: {\n raw?: boolean;\n } = {},\n): Resolver<Input, Context, Output | Input> {\n return async (values, _, options) => {\n let result = schema['~standard'].validate(values);\n if (result instanceof Promise) {\n result = await result;\n }\n\n if (result.issues) {\n const errors = parseErrorSchema(\n result.issues,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n );\n\n return {\n values: {},\n errors: toNestErrors(errors, options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.value,\n errors: {},\n };\n };\n}\n"],"names":["schema","_schemaOptions","resolverOptions","values","_","options","_temp2","result","issues","errors","typeschemaErrors","validateAllFieldCriteria","schemaErrors","Object","assign","length","error","path","_path","join","message","type","types","messages","appendErrors","concat","shift","parseErrorSchema","shouldUseNativeValidation","criteriaMode","toNestErrors","validateFieldsNatively","raw","value","validate","_temp","Promise","resolve","then","_result","e","reject"],"mappings":"6FAmFM,SACJA,EACAC,EACAC,GAIA,YAJAA,IAAAA,IAAAA,EAEI,IAEUC,SAAAA,EAAQC,EAAGC,GAAO,QAAIC,EAAA,WAMlC,GAAIC,EAAOC,OAAQ,CACjB,IAAMC,EAvFa,SACvBC,EACAC,GAKA,IAHA,IAAMC,EAAeC,OAAOC,OAAO,GAAIJ,GACjCD,EAAqC,GAEpCG,EAAaG,QAAU,CAC5B,IAAMC,EAAQN,EAAiB,GAE/B,GAAKM,EAAMC,KAAX,CAGA,IAAMC,EAAQF,EAAMC,KAAKE,KAAK,KAM9B,GAJKV,EAAOS,KACVT,EAAOS,GAAS,CAAEE,QAASJ,EAAMI,QAASC,KAAM,KAG9CV,EAA0B,CAC5B,IAAMW,EAAQb,EAAOS,GAAOI,MACtBC,EAAWD,GAASA,EAAM,IAEhCb,EAAOS,GAASM,EAAYA,aAC1BN,EACAP,EACAF,EACA,GACAc,EACK,GAAgBE,OAAOF,EAAsBP,EAAMI,SACpDJ,EAAMI,QAEd,CAEAR,EAAac,OAtBb,CAuBF,CAEA,OAAOjB,CACT,CAiDqBkB,CACbpB,EAAOC,QACNH,EAAQuB,2BAAsD,QAAzBvB,EAAQwB,cAGhD,MAAO,CACL1B,OAAQ,CAAE,EACVM,OAAQqB,EAAAA,aAAarB,EAAQJ,GAEjC,CAIA,OAFAA,EAAQuB,2BAA6BG,yBAAuB,CAAA,EAAI1B,GAEzD,CACLF,OAAQD,EAAgB8B,IAAMnB,OAAOC,OAAO,CAAA,EAAIX,GAAUI,EAAO0B,MACjExB,OAAQ,CAAA,EACR,EAtBEF,EAASP,EAAO,aAAakC,SAAS/B,GAAQgC,EAC9C5B,WAAAA,GAAAA,aAAkB6B,QAAOA,OAAAA,QAAAC,QACZ9B,GAAM+B,cAAAC,GAArBhC,EAAMgC,CAAgB,GADpBhC,UACoB6B,QAAAC,QAAAF,GAAAA,EAAAG,KAAAH,EAAAG,KAAAhC,GAAAA,IAqB1B,CAAC,MAAAkC,GAAAJ,OAAAA,QAAAK,OAAAD,EACH,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeschema.modern.mjs","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\
|
|
1
|
+
{"version":3,"file":"typeschema.modern.mjs","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nconst parseErrorSchema = (\n typeschemaErrors: readonly StandardSchemaV1.Issue[],\n validateAllFieldCriteria: boolean,\n): FieldErrors => {\n const schemaErrors = Object.assign([], typeschemaErrors);\n const errors: Record<string, FieldError> = {};\n\n for (; schemaErrors.length; ) {\n const error = typeschemaErrors[0];\n\n if (!error.path) {\n continue;\n }\n const _path = error.path.join('.');\n\n if (!errors[_path]) {\n errors[_path] = { message: error.message, type: '' };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[''];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '',\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n schemaErrors.shift();\n }\n\n return errors;\n};\n\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions?: never,\n resolverOptions?: {\n raw?: false;\n },\n): Resolver<Input, Context, Output>;\n\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions: never | undefined,\n resolverOptions: {\n raw: true;\n },\n): Resolver<Input, Context, Input>;\n\n/**\n * Creates a resolver for react-hook-form using TypeSchema validation\n * @param {any} schema - The TypeSchema to validate against\n * @param {any} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = z.object({\n * name: z.string().required(),\n * age: z.number().required(),\n * });\n *\n * useForm({\n * resolver: typeschemaResolver(schema)\n * });\n */\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions?: never,\n resolverOptions: {\n raw?: boolean;\n } = {},\n): Resolver<Input, Context, Output | Input> {\n return async (values, _, options) => {\n let result = schema['~standard'].validate(values);\n if (result instanceof Promise) {\n result = await result;\n }\n\n if (result.issues) {\n const errors = parseErrorSchema(\n result.issues,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n );\n\n return {\n values: {},\n errors: toNestErrors(errors, options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.value,\n errors: {},\n };\n };\n}\n"],"names":["typeschemaResolver","schema","_schemaOptions","resolverOptions","async","values","_","options","result","validate","Promise","issues","errors","parseErrorSchema","typeschemaErrors","validateAllFieldCriteria","schemaErrors","Object","assign","length","error","path","_path","join","message","type","types","messages","appendErrors","concat","shift","shouldUseNativeValidation","criteriaMode","toNestErrors","validateFieldsNatively","raw","value"],"mappings":"8HAmFM,SAAUA,EACdC,EACAC,EACAC,EAEI,IAEJ,OAAOC,MAAOC,EAAQC,EAAGC,KACvB,IAAIC,EAASP,EAAO,aAAaQ,SAASJ,GAK1C,GAJIG,aAAkBE,UACpBF,QAAeA,GAGbA,EAAOG,OAAQ,CACjB,MAAMC,EAvFaC,EACvBC,EACAC,KAEA,MAAMC,EAAeC,OAAOC,OAAO,GAAIJ,GACjCF,EAAqC,CAAE,EAE7C,KAAOI,EAAaG,QAAU,CAC5B,MAAMC,EAAQN,EAAiB,GAE/B,IAAKM,EAAMC,KACT,SAEF,MAAMC,EAAQF,EAAMC,KAAKE,KAAK,KAM9B,GAJKX,EAAOU,KACVV,EAAOU,GAAS,CAAEE,QAASJ,EAAMI,QAASC,KAAM,KAG9CV,EAA0B,CAC5B,MAAMW,EAAQd,EAAOU,GAAOI,MACtBC,EAAWD,GAASA,EAAM,IAEhCd,EAAOU,GAASM,EACdN,EACAP,EACAH,EACA,GACAe,EACK,GAAgBE,OAAOF,EAAsBP,EAAMI,SACpDJ,EAAMI,QAEd,CAEAR,EAAac,OACf,CAEA,OAAOlB,GAkDYC,CACbL,EAAOG,QACNJ,EAAQwB,2BAAsD,QAAzBxB,EAAQyB,cAGhD,MAAO,CACL3B,OAAQ,CAAA,EACRO,OAAQqB,EAAarB,EAAQL,GAEjC,CAIA,OAFAA,EAAQwB,2BAA6BG,EAAuB,CAAA,EAAI3B,GAEzD,CACLF,OAAQF,EAAgBgC,IAAMlB,OAAOC,OAAO,CAAA,EAAIb,GAAUG,EAAO4B,MACjExB,OAAQ,CAAA,GAGd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeschema.module.js","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\
|
|
1
|
+
{"version":3,"file":"typeschema.module.js","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nconst parseErrorSchema = (\n typeschemaErrors: readonly StandardSchemaV1.Issue[],\n validateAllFieldCriteria: boolean,\n): FieldErrors => {\n const schemaErrors = Object.assign([], typeschemaErrors);\n const errors: Record<string, FieldError> = {};\n\n for (; schemaErrors.length; ) {\n const error = typeschemaErrors[0];\n\n if (!error.path) {\n continue;\n }\n const _path = error.path.join('.');\n\n if (!errors[_path]) {\n errors[_path] = { message: error.message, type: '' };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[''];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '',\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n schemaErrors.shift();\n }\n\n return errors;\n};\n\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions?: never,\n resolverOptions?: {\n raw?: false;\n },\n): Resolver<Input, Context, Output>;\n\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions: never | undefined,\n resolverOptions: {\n raw: true;\n },\n): Resolver<Input, Context, Input>;\n\n/**\n * Creates a resolver for react-hook-form using TypeSchema validation\n * @param {any} schema - The TypeSchema to validate against\n * @param {any} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = z.object({\n * name: z.string().required(),\n * age: z.number().required(),\n * });\n *\n * useForm({\n * resolver: typeschemaResolver(schema)\n * });\n */\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions?: never,\n resolverOptions: {\n raw?: boolean;\n } = {},\n): Resolver<Input, Context, Output | Input> {\n return async (values, _, options) => {\n let result = schema['~standard'].validate(values);\n if (result instanceof Promise) {\n result = await result;\n }\n\n if (result.issues) {\n const errors = parseErrorSchema(\n result.issues,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n );\n\n return {\n values: {},\n errors: toNestErrors(errors, options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.value,\n errors: {},\n };\n };\n}\n"],"names":["typeschemaResolver","schema","_schemaOptions","resolverOptions","values","_","options","_temp2","result","issues","errors","typeschemaErrors","validateAllFieldCriteria","schemaErrors","Object","assign","length","error","path","_path","join","message","type","types","messages","appendErrors","concat","shift","parseErrorSchema","shouldUseNativeValidation","criteriaMode","toNestErrors","validateFieldsNatively","raw","value","validate","_temp","Promise","resolve","then","_result","e","reject"],"mappings":"8HAmFM,SAAUA,EACdC,EACAC,EACAC,GAIA,YAJAA,IAAAA,IAAAA,EAEI,IAEUC,SAAAA,EAAQC,EAAGC,GAAO,QAAIC,EAAA,WAMlC,GAAIC,EAAOC,OAAQ,CACjB,IAAMC,EAvFa,SACvBC,EACAC,GAKA,IAHA,IAAMC,EAAeC,OAAOC,OAAO,GAAIJ,GACjCD,EAAqC,GAEpCG,EAAaG,QAAU,CAC5B,IAAMC,EAAQN,EAAiB,GAE/B,GAAKM,EAAMC,KAAX,CAGA,IAAMC,EAAQF,EAAMC,KAAKE,KAAK,KAM9B,GAJKV,EAAOS,KACVT,EAAOS,GAAS,CAAEE,QAASJ,EAAMI,QAASC,KAAM,KAG9CV,EAA0B,CAC5B,IAAMW,EAAQb,EAAOS,GAAOI,MACtBC,EAAWD,GAASA,EAAM,IAEhCb,EAAOS,GAASM,EACdN,EACAP,EACAF,EACA,GACAc,EACK,GAAgBE,OAAOF,EAAsBP,EAAMI,SACpDJ,EAAMI,QAEd,CAEAR,EAAac,OAtBb,CAuBF,CAEA,OAAOjB,CACT,CAiDqBkB,CACbpB,EAAOC,QACNH,EAAQuB,2BAAsD,QAAzBvB,EAAQwB,cAGhD,MAAO,CACL1B,OAAQ,CAAE,EACVM,OAAQqB,EAAarB,EAAQJ,GAEjC,CAIA,OAFAA,EAAQuB,2BAA6BG,EAAuB,CAAA,EAAI1B,GAEzD,CACLF,OAAQD,EAAgB8B,IAAMnB,OAAOC,OAAO,CAAA,EAAIX,GAAUI,EAAO0B,MACjExB,OAAQ,CAAA,EACR,EAtBEF,EAASP,EAAO,aAAakC,SAAS/B,GAAQgC,EAC9C5B,WAAAA,GAAAA,aAAkB6B,QAAOA,OAAAA,QAAAC,QACZ9B,GAAM+B,cAAAC,GAArBhC,EAAMgC,CAAgB,GADpBhC,UACoB6B,QAAAC,QAAAF,GAAAA,EAAAG,KAAAH,EAAAG,KAAAhC,GAAAA,IAqB1B,CAAC,MAAAkC,GAAAJ,OAAAA,QAAAK,OAAAD,EACH,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeschema.umd.js","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\
|
|
1
|
+
{"version":3,"file":"typeschema.umd.js","sources":["../src/typeschema.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n FieldError,\n FieldErrors,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\nconst parseErrorSchema = (\n typeschemaErrors: readonly StandardSchemaV1.Issue[],\n validateAllFieldCriteria: boolean,\n): FieldErrors => {\n const schemaErrors = Object.assign([], typeschemaErrors);\n const errors: Record<string, FieldError> = {};\n\n for (; schemaErrors.length; ) {\n const error = typeschemaErrors[0];\n\n if (!error.path) {\n continue;\n }\n const _path = error.path.join('.');\n\n if (!errors[_path]) {\n errors[_path] = { message: error.message, type: '' };\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[''];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n '',\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n schemaErrors.shift();\n }\n\n return errors;\n};\n\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions?: never,\n resolverOptions?: {\n raw?: false;\n },\n): Resolver<Input, Context, Output>;\n\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions: never | undefined,\n resolverOptions: {\n raw: true;\n },\n): Resolver<Input, Context, Input>;\n\n/**\n * Creates a resolver for react-hook-form using TypeSchema validation\n * @param {any} schema - The TypeSchema to validate against\n * @param {any} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = z.object({\n * name: z.string().required(),\n * age: z.number().required(),\n * });\n *\n * useForm({\n * resolver: typeschemaResolver(schema)\n * });\n */\nexport function typeschemaResolver<Input extends FieldValues, Context, Output>(\n schema: StandardSchemaV1<Input, Output>,\n _schemaOptions?: never,\n resolverOptions: {\n raw?: boolean;\n } = {},\n): Resolver<Input, Context, Output | Input> {\n return async (values, _, options) => {\n let result = schema['~standard'].validate(values);\n if (result instanceof Promise) {\n result = await result;\n }\n\n if (result.issues) {\n const errors = parseErrorSchema(\n result.issues,\n !options.shouldUseNativeValidation && options.criteriaMode === 'all',\n );\n\n return {\n values: {},\n errors: toNestErrors(errors, options),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : result.value,\n errors: {},\n };\n };\n}\n"],"names":["schema","_schemaOptions","resolverOptions","values","_","options","_temp2","result","issues","errors","typeschemaErrors","validateAllFieldCriteria","schemaErrors","Object","assign","length","error","path","_path","join","message","type","types","messages","appendErrors","concat","shift","parseErrorSchema","shouldUseNativeValidation","criteriaMode","toNestErrors","validateFieldsNatively","raw","value","validate","_temp","Promise","resolve","then","_result","e","reject"],"mappings":"oZAmFM,SACJA,EACAC,EACAC,GAIA,YAJAA,IAAAA,IAAAA,EAEI,IAEUC,SAAAA,EAAQC,EAAGC,GAAO,QAAIC,EAAA,WAMlC,GAAIC,EAAOC,OAAQ,CACjB,IAAMC,EAvFa,SACvBC,EACAC,GAKA,IAHA,IAAMC,EAAeC,OAAOC,OAAO,GAAIJ,GACjCD,EAAqC,GAEpCG,EAAaG,QAAU,CAC5B,IAAMC,EAAQN,EAAiB,GAE/B,GAAKM,EAAMC,KAAX,CAGA,IAAMC,EAAQF,EAAMC,KAAKE,KAAK,KAM9B,GAJKV,EAAOS,KACVT,EAAOS,GAAS,CAAEE,QAASJ,EAAMI,QAASC,KAAM,KAG9CV,EAA0B,CAC5B,IAAMW,EAAQb,EAAOS,GAAOI,MACtBC,EAAWD,GAASA,EAAM,IAEhCb,EAAOS,GAASM,EAAYA,aAC1BN,EACAP,EACAF,EACA,GACAc,EACK,GAAgBE,OAAOF,EAAsBP,EAAMI,SACpDJ,EAAMI,QAEd,CAEAR,EAAac,OAtBb,CAuBF,CAEA,OAAOjB,CACT,CAiDqBkB,CACbpB,EAAOC,QACNH,EAAQuB,2BAAsD,QAAzBvB,EAAQwB,cAGhD,MAAO,CACL1B,OAAQ,CAAE,EACVM,OAAQqB,EAAAA,aAAarB,EAAQJ,GAEjC,CAIA,OAFAA,EAAQuB,2BAA6BG,yBAAuB,CAAA,EAAI1B,GAEzD,CACLF,OAAQD,EAAgB8B,IAAMnB,OAAOC,OAAO,CAAA,EAAIX,GAAUI,EAAO0B,MACjExB,OAAQ,CAAA,EACR,EAtBEF,EAASP,EAAO,aAAakC,SAAS/B,GAAQgC,EAC9C5B,WAAAA,GAAAA,aAAkB6B,QAAOA,OAAAA,QAAAC,QACZ9B,GAAM+B,cAAAC,GAArBhC,EAAMgC,CAAgB,GADpBhC,UACoB6B,QAAAC,QAAAF,GAAAA,EAAAG,KAAAH,EAAAG,KAAAhC,GAAAA,IAqB1B,CAAC,MAAAkC,GAAAJ,OAAAA,QAAAK,OAAAD,EACH,CAAA,CAAA"}
|
package/typeschema/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import user from '@testing-library/user-event';
|
|
|
3
3
|
import type { Infer } from '@typeschema/main';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { useForm } from 'react-hook-form';
|
|
6
|
-
import { z } from 'zod';
|
|
6
|
+
import { z } from 'zod/v3';
|
|
7
7
|
import { typeschemaResolver } from '..';
|
|
8
8
|
|
|
9
9
|
const USERNAME_REQUIRED_MESSAGE = 'username field is required';
|
|
@@ -3,7 +3,7 @@ import user from '@testing-library/user-event';
|
|
|
3
3
|
import type { Infer } from '@typeschema/main';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { useForm } from 'react-hook-form';
|
|
6
|
-
import { z } from 'zod';
|
|
6
|
+
import { z } from 'zod/v3';
|
|
7
7
|
import { typeschemaResolver } from '..';
|
|
8
8
|
|
|
9
9
|
const schema = z.object({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as typeschema from '@typeschema/main';
|
|
2
2
|
import { Resolver, SubmitHandler, useForm } from 'react-hook-form';
|
|
3
|
-
import { z } from 'zod';
|
|
3
|
+
import { z } from 'zod/v3';
|
|
4
4
|
import { typeschemaResolver } from '..';
|
|
5
5
|
import { fields, invalidData, schema, validData } from './__fixtures__/data';
|
|
6
6
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
|
|
2
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
3
|
import {
|
|
3
4
|
FieldError,
|
|
4
5
|
FieldErrors,
|
|
@@ -6,7 +7,6 @@ import {
|
|
|
6
7
|
Resolver,
|
|
7
8
|
appendErrors,
|
|
8
9
|
} from 'react-hook-form';
|
|
9
|
-
import { StandardSchemaV1 } from 'zod/lib/standard-schema';
|
|
10
10
|
|
|
11
11
|
const parseErrorSchema = (
|
|
12
12
|
typeschemaErrors: readonly StandardSchemaV1.Issue[],
|
package/valibot/package.json
CHANGED
package/vest/package.json
CHANGED
package/vine/package.json
CHANGED
package/yup/package.json
CHANGED
package/zod/dist/zod.d.ts
CHANGED
|
@@ -1,10 +1,49 @@
|
|
|
1
1
|
import { FieldValues, Resolver } from 'react-hook-form';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
raw?: false;
|
|
6
|
-
}): Resolver<Input, Context, Output>;
|
|
7
|
-
export declare function zodResolver<Input extends FieldValues, Context, Output>(schema: z.ZodSchema<Output, any, Input>, schemaOptions: Partial<z.ParseParams> | undefined, resolverOptions: {
|
|
2
|
+
import * as z3 from 'zod/v3';
|
|
3
|
+
import * as z4 from 'zod/v4/core';
|
|
4
|
+
type RawResolverOptions = {
|
|
8
5
|
mode?: 'async' | 'sync';
|
|
9
6
|
raw: true;
|
|
10
|
-
}
|
|
7
|
+
};
|
|
8
|
+
type NonRawResolverOptions = {
|
|
9
|
+
mode?: 'async' | 'sync';
|
|
10
|
+
raw?: false;
|
|
11
|
+
};
|
|
12
|
+
interface Zod3Type<O = unknown, I = unknown> {
|
|
13
|
+
_output: O;
|
|
14
|
+
_input: I;
|
|
15
|
+
_def: {
|
|
16
|
+
typeName: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
type IsUnresolved<T> = PropertyKey extends keyof T ? true : false;
|
|
20
|
+
type UnresolvedFallback<T, Fallback> = IsUnresolved<typeof z3> extends true ? Fallback : T;
|
|
21
|
+
type FallbackIssue = {
|
|
22
|
+
code: string;
|
|
23
|
+
message: string;
|
|
24
|
+
path: (string | number)[];
|
|
25
|
+
};
|
|
26
|
+
type Zod3ParseParams = UnresolvedFallback<z3.ParseParams, {
|
|
27
|
+
path?: (string | number)[];
|
|
28
|
+
errorMap?: (iss: FallbackIssue, ctx: {
|
|
29
|
+
defaultError: string;
|
|
30
|
+
data: any;
|
|
31
|
+
}) => {
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
async?: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
type Zod4ParseParams = UnresolvedFallback<z4.ParseContext<z4.$ZodIssue>, {
|
|
37
|
+
readonly error?: (iss: FallbackIssue) => null | undefined | string | {
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
readonly reportInput?: boolean;
|
|
41
|
+
readonly jitless?: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
export declare function zodResolver<Input extends FieldValues, Context, Output>(schema: Zod3Type<Output, Input>, schemaOptions?: Zod3ParseParams, resolverOptions?: NonRawResolverOptions): Resolver<Input, Context, Output>;
|
|
44
|
+
export declare function zodResolver<Input extends FieldValues, Context, Output>(schema: Zod3Type<Output, Input>, schemaOptions: Zod3ParseParams | undefined, resolverOptions: RawResolverOptions): Resolver<Input, Context, Input>;
|
|
45
|
+
export declare function zodResolver<Input extends FieldValues, Context, Output, T extends z4.$ZodType<Output, Input> = z4.$ZodType<Output, Input>>(schema: T, schemaOptions?: Zod4ParseParams, // already partial
|
|
46
|
+
resolverOptions?: NonRawResolverOptions): Resolver<z4.input<T>, Context, z4.output<T>>;
|
|
47
|
+
export declare function zodResolver<Input extends FieldValues, Context, Output, T extends z4.$ZodType<Output, Input> = z4.$ZodType<Output, Input>>(schema: z4.$ZodType<Output, Input>, schemaOptions: Zod4ParseParams | undefined, // already partial
|
|
48
|
+
resolverOptions: RawResolverOptions): Resolver<z4.input<T>, Context, z4.input<T>>;
|
|
49
|
+
export {};
|
package/zod/dist/zod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var e=require("@hookform/resolvers"),r=require("react-hook-form");function n(e,r,n){function t(n,t){var o;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(o=n._zod).traits??(o.traits=new Set),n._zod.traits.add(e),r(n,t);for(const e in i.prototype)e in n||Object.defineProperty(n,e,{value:i.prototype[e].bind(n)});n._zod.constr=i,n._zod.def=t}const o=n?.Parent??Object;class s extends o{}function i(e){var r;const o=n?.Parent?new s:this;t(o,e),(r=o._zod).deferred??(r.deferred=[]);for(const e of o._zod.deferred)e();return o}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(i,"init",{value:t}),Object.defineProperty(i,Symbol.hasInstance,{value:r=>!!(n?.Parent&&r instanceof n.Parent)||r?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class t extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const o={};function s(e){return e&&Object.assign(o,e),o}function i(e,r){return"bigint"==typeof r?r.toString():r}function a(e){return"string"==typeof e?e:e?.message}function u(e,r,n){const t={...e,path:e.path??[]};if(!e.message){const o=a(e.inst?._zod.def?.error?.(e))??a(r?.error?.(e))??a(n.customError?.(e))??a(n.localeError?.(e))??"Invalid input";t.message=o}return delete t.inst,delete t.continue,r?.reportInput||delete t.input,t}const c=(e,r)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:r,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(r,i,2),enumerable:!0})},d=n("$ZodError",c),f=n("$ZodError",c,{Parent:Error}),l=/* @__PURE__*/(e=>(r,n,o,i)=>{const a=o?Object.assign(o,{async:!1}):{async:!1},c=r._zod.run({value:n,issues:[]},a);if(c instanceof Promise)throw new t;if(c.issues.length){const r=new(i?.Err??e)(c.issues.map(e=>u(e,a,s())));throw Error.captureStackTrace(r,i?.callee),r}return c.value})(f),p=/* @__PURE__*/(e=>async(r,n,t,o)=>{const i=t?Object.assign(t,{async:!0}):{async:!0};let a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const r=new(o?.Err??e)(a.issues.map(e=>u(e,i,s())));throw Error.captureStackTrace(r,o?.callee),r}return a.value})(f);function v(e,r){try{var n=e()}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}function m(e,n){for(var t={};e.length;){var o=e[0],s=o.code,i=o.message,a=o.path.join(".");if(!t[a])if("unionErrors"in o){var u=o.unionErrors[0].errors[0];t[a]={message:u.message,type:u.code}}else t[a]={message:i,type:s};if("unionErrors"in o&&o.unionErrors.forEach(function(r){return r.errors.forEach(function(r){return e.push(r)})}),n){var c=t[a].types,d=c&&c[o.code];t[a]=r.appendErrors(a,n,t,s,d?[].concat(d,o.message):o.message)}e.shift()}return t}function y(e,n){for(var t={};e.length;){var o=e[0],s=o.code,i=o.message,a=o.path.join(".");if(!t[a])if("invalid_union"===o.code){var u=o.errors[0][0];t[a]={message:u.message,type:u.code}}else t[a]={message:i,type:s};if("invalid_union"===o.code&&o.errors.forEach(function(r){return r.forEach(function(r){return e.push(r)})}),n){var c=t[a].types,d=c&&c[o.code];t[a]=r.appendErrors(a,n,t,s,d?[].concat(d,o.message):o.message)}e.shift()}return t}exports.zodResolver=function(r,n,t){if(void 0===t&&(t={}),function(e){return"_def"in e&&"object"==typeof e._def&&"typeName"in e._def}(r))return function(o,s,i){try{return Promise.resolve(v(function(){return Promise.resolve(r["sync"===t.mode?"parse":"parseAsync"](o,n)).then(function(r){return i.shouldUseNativeValidation&&e.validateFieldsNatively({},i),{errors:{},values:t.raw?Object.assign({},o):r}})},function(r){if(function(e){return Array.isArray(null==e?void 0:e.issues)}(r))return{values:{},errors:e.toNestErrors(m(r.errors,!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)};throw r}))}catch(e){return Promise.reject(e)}};if(function(e){return"_zod"in e&&"object"==typeof e._zod}(r))return function(o,s,i){try{return Promise.resolve(v(function(){return Promise.resolve(("sync"===t.mode?l:p)(r,o,n)).then(function(r){return i.shouldUseNativeValidation&&e.validateFieldsNatively({},i),{errors:{},values:t.raw?Object.assign({},o):r}})},function(r){if(function(e){return e instanceof d}(r))return{values:{},errors:e.toNestErrors(y(r.issues,!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)};throw r}))}catch(e){return Promise.reject(e)}};throw new Error("Invalid input: not a Zod schema")};
|
|
2
2
|
//# sourceMappingURL=zod.js.map
|