@hookform/resolvers 5.4.2 → 5.5.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/ajv/dist/ajv.js.map +1 -1
- package/ajv/dist/ajv.modern.mjs.map +1 -1
- package/ajv/dist/ajv.module.js.map +1 -1
- package/ajv/dist/ajv.umd.js.map +1 -1
- package/arktype/dist/arktype.js.map +1 -1
- package/arktype/dist/arktype.modern.mjs.map +1 -1
- package/arktype/dist/arktype.module.js.map +1 -1
- package/arktype/dist/arktype.umd.js.map +1 -1
- package/arktype/src/__tests__/__snapshots__/arktype.ts.snap +11 -11
- package/arktype/src/__tests__/arktype.ts +15 -6
- package/ata-validator/dist/ata-validator.js.map +1 -1
- package/ata-validator/dist/ata-validator.modern.mjs.map +1 -1
- package/ata-validator/dist/ata-validator.module.js.map +1 -1
- package/ata-validator/dist/ata-validator.umd.js.map +1 -1
- package/class-validator/dist/class-validator.js.map +1 -1
- package/class-validator/dist/class-validator.modern.mjs.map +1 -1
- package/class-validator/dist/class-validator.module.js.map +1 -1
- package/class-validator/dist/class-validator.umd.js.map +1 -1
- package/computed-types/dist/computed-types.js.map +1 -1
- package/computed-types/dist/computed-types.modern.mjs.map +1 -1
- package/computed-types/dist/computed-types.module.js.map +1 -1
- package/computed-types/dist/computed-types.umd.js.map +1 -1
- package/computed-types/src/__tests__/computed-types.ts +15 -6
- package/dist/resolvers.js.map +1 -1
- package/dist/resolvers.mjs.map +1 -1
- package/dist/resolvers.module.js.map +1 -1
- package/dist/resolvers.umd.js.map +1 -1
- package/effect-ts/dist/effect-ts.js.map +1 -1
- package/effect-ts/dist/effect-ts.modern.mjs.map +1 -1
- package/effect-ts/dist/effect-ts.module.js.map +1 -1
- package/effect-ts/dist/effect-ts.umd.js.map +1 -1
- package/effect-ts/src/__tests__/effect-ts.ts +15 -6
- package/fluentvalidation-ts/dist/fluentvalidation-ts.js.map +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.modern.mjs.map +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.module.js.map +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.umd.js.map +1 -1
- package/io-ts/dist/io-ts.js.map +1 -1
- package/io-ts/dist/io-ts.modern.mjs.map +1 -1
- package/io-ts/dist/io-ts.module.js.map +1 -1
- package/io-ts/dist/io-ts.umd.js.map +1 -1
- package/io-ts/src/__tests__/io-ts.ts +15 -6
- package/joi/dist/joi.js.map +1 -1
- package/joi/dist/joi.modern.mjs.map +1 -1
- package/joi/dist/joi.module.js.map +1 -1
- package/joi/dist/joi.umd.js.map +1 -1
- package/nope/dist/nope.js.map +1 -1
- package/nope/dist/nope.modern.mjs.map +1 -1
- package/nope/dist/nope.module.js.map +1 -1
- package/nope/dist/nope.umd.js.map +1 -1
- package/nope/dist/types.d.ts +2 -1
- package/nope/src/nope.ts +7 -1
- package/nope/src/types.ts +7 -1
- package/package.json +31 -28
- package/standard-schema/dist/standard-schema.js.map +1 -1
- package/standard-schema/dist/standard-schema.modern.mjs.map +1 -1
- package/standard-schema/dist/standard-schema.module.js.map +1 -1
- package/standard-schema/dist/standard-schema.umd.js.map +1 -1
- package/standard-schema/src/__tests__/__snapshots__/standard-schema.ts.snap +31 -0
- package/standard-schema/src/__tests__/standard-schema.ts +21 -13
- package/superstruct/dist/superstruct.d.ts +5 -0
- package/superstruct/dist/superstruct.js.map +1 -1
- package/superstruct/dist/superstruct.modern.mjs.map +1 -1
- package/superstruct/dist/superstruct.module.js.map +1 -1
- package/superstruct/dist/superstruct.umd.js.map +1 -1
- package/superstruct/src/__tests__/superstruct.ts +22 -8
- package/superstruct/src/superstruct.ts +13 -0
- package/typanion/dist/typanion.js.map +1 -1
- package/typanion/dist/typanion.modern.mjs.map +1 -1
- package/typanion/dist/typanion.module.js.map +1 -1
- package/typanion/dist/typanion.umd.js.map +1 -1
- package/typanion/src/__tests__/typanion.ts +8 -3
- package/typebox/dist/typebox.js.map +1 -1
- package/typebox/dist/typebox.modern.mjs.map +1 -1
- package/typebox/dist/typebox.module.js.map +1 -1
- package/typebox/dist/typebox.umd.js.map +1 -1
- package/typebox/src/__tests__/typebox.ts +31 -18
- package/typeschema/dist/typeschema.js +1 -1
- package/typeschema/dist/typeschema.js.map +1 -1
- package/typeschema/dist/typeschema.mjs +1 -1
- package/typeschema/dist/typeschema.modern.mjs +1 -1
- package/typeschema/dist/typeschema.modern.mjs.map +1 -1
- package/typeschema/dist/typeschema.module.js +1 -1
- package/typeschema/dist/typeschema.module.js.map +1 -1
- package/typeschema/dist/typeschema.umd.js +1 -1
- package/typeschema/dist/typeschema.umd.js.map +1 -1
- package/typeschema/src/__tests__/Form-native-validation.tsx +1 -2
- package/typeschema/src/__tests__/Form.tsx +1 -2
- package/typeschema/src/__tests__/typeschema.ts +23 -15
- package/typeschema/src/typeschema.ts +6 -6
- package/valibot/dist/valibot.js.map +1 -1
- package/valibot/dist/valibot.modern.mjs.map +1 -1
- package/valibot/dist/valibot.module.js.map +1 -1
- package/valibot/dist/valibot.umd.js.map +1 -1
- package/valibot/src/__tests__/valibot.ts +15 -6
- package/vest/dist/vest.js.map +1 -1
- package/vest/dist/vest.modern.mjs.map +1 -1
- package/vest/dist/vest.module.js.map +1 -1
- package/vest/dist/vest.umd.js.map +1 -1
- package/vine/dist/vine.js.map +1 -1
- package/vine/dist/vine.modern.mjs.map +1 -1
- package/vine/dist/vine.module.js.map +1 -1
- package/vine/dist/vine.umd.js.map +1 -1
- package/vine/src/__tests__/vine.ts +15 -6
- package/yup/dist/yup.js.map +1 -1
- package/yup/dist/yup.modern.mjs.map +1 -1
- package/yup/dist/yup.module.js.map +1 -1
- package/yup/dist/yup.umd.js.map +1 -1
- package/yup/src/__tests__/yup.ts +15 -6
- package/yup/src/yup.ts +10 -2
- 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/src/__tests__/__snapshots__/zod-v3.ts.snap +430 -0
- package/zod/src/__tests__/__snapshots__/zod-v4-mini.ts.snap +472 -0
- package/zod/src/__tests__/__snapshots__/zod-v4.ts.snap +434 -0
- package/zod/src/__tests__/zod-v3.ts +45 -6
- package/zod/src/__tests__/zod-v4-mini.ts +21 -11
- package/zod/src/__tests__/zod-v4.ts +47 -11
- package/zod/src/zod.ts +15 -2
package/zod/src/zod.ts
CHANGED
|
@@ -40,7 +40,14 @@ function parseZod3Issues(
|
|
|
40
40
|
|
|
41
41
|
if (!errors[_path]) {
|
|
42
42
|
if ('unionErrors' in error) {
|
|
43
|
-
|
|
43
|
+
// Surface the error from whichever union member came closest to
|
|
44
|
+
// matching (fewest issues), rather than always the first member —
|
|
45
|
+
// the first member isn't necessarily the one the input was meant for.
|
|
46
|
+
const closestUnionError = error.unionErrors.reduce(
|
|
47
|
+
(closest, current) =>
|
|
48
|
+
current.errors.length < closest.errors.length ? current : closest,
|
|
49
|
+
);
|
|
50
|
+
const unionError = closestUnionError.errors[0];
|
|
44
51
|
|
|
45
52
|
errors[_path] = {
|
|
46
53
|
message: unionError.message,
|
|
@@ -91,7 +98,13 @@ function parseZod4Issues(
|
|
|
91
98
|
|
|
92
99
|
if (!errors[_path]) {
|
|
93
100
|
if (error.code === 'invalid_union' && error.errors.length > 0) {
|
|
94
|
-
|
|
101
|
+
// Surface the error from whichever union member came closest to
|
|
102
|
+
// matching (fewest issues), rather than always the first member —
|
|
103
|
+
// the first member isn't necessarily the one the input was meant for.
|
|
104
|
+
const closestBranch = error.errors.reduce((closest, branch) =>
|
|
105
|
+
branch.length < closest.length ? branch : closest,
|
|
106
|
+
);
|
|
107
|
+
const unionError = closestBranch[0];
|
|
95
108
|
|
|
96
109
|
errors[_path] = {
|
|
97
110
|
message: unionError.message,
|