@hookform/resolvers 3.10.0 → 4.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 +108 -6
- package/ajv/dist/ajv.d.ts +20 -0
- package/ajv/dist/ajv.js +1 -1
- package/ajv/dist/ajv.js.map +1 -1
- package/ajv/dist/ajv.mjs +1 -1
- package/ajv/dist/ajv.modern.mjs +1 -1
- package/ajv/dist/ajv.modern.mjs.map +1 -1
- package/ajv/dist/ajv.module.js +1 -1
- package/ajv/dist/ajv.module.js.map +1 -1
- package/ajv/dist/ajv.umd.js +1 -1
- package/ajv/dist/ajv.umd.js.map +1 -1
- package/ajv/dist/types.d.ts +8 -0
- package/ajv/src/__tests__/__fixtures__/data-errors.ts +216 -0
- package/ajv/src/__tests__/__snapshots__/ajv-errors.ts.snap +462 -0
- package/ajv/src/__tests__/__snapshots__/ajv.ts.snap +6 -6
- package/ajv/src/__tests__/ajv-errors.ts +227 -0
- package/ajv/src/ajv.ts +47 -14
- package/ajv/src/types.ts +8 -0
- package/arktype/dist/arktype.d.ts +20 -2
- package/arktype/dist/arktype.js +1 -1
- package/arktype/dist/arktype.js.map +1 -1
- package/arktype/dist/arktype.mjs +1 -1
- package/arktype/dist/arktype.modern.mjs +1 -1
- package/arktype/dist/arktype.modern.mjs.map +1 -1
- package/arktype/dist/arktype.module.js +1 -1
- package/arktype/dist/arktype.module.js.map +1 -1
- package/arktype/dist/arktype.umd.js +1 -1
- package/arktype/dist/arktype.umd.js.map +1 -1
- package/arktype/dist/index.d.ts +0 -1
- package/arktype/package.json +1 -1
- package/arktype/src/__tests__/Form-native-validation.tsx +3 -3
- package/arktype/src/__tests__/Form.tsx +34 -8
- package/arktype/src/__tests__/__fixtures__/data.ts +2 -2
- package/arktype/src/__tests__/__snapshots__/arktype.ts.snap +22 -415
- package/arktype/src/arktype.ts +46 -15
- package/arktype/src/index.ts +0 -1
- package/class-validator/dist/class-validator.d.ts +29 -2
- package/class-validator/dist/class-validator.js +1 -1
- package/class-validator/dist/class-validator.js.map +1 -1
- package/class-validator/dist/class-validator.mjs +1 -1
- package/class-validator/dist/class-validator.modern.mjs +1 -1
- package/class-validator/dist/class-validator.modern.mjs.map +1 -1
- package/class-validator/dist/class-validator.module.js +1 -1
- package/class-validator/dist/class-validator.module.js.map +1 -1
- package/class-validator/dist/class-validator.umd.js +1 -1
- package/class-validator/dist/class-validator.umd.js.map +1 -1
- package/class-validator/dist/index.d.ts +0 -1
- package/class-validator/src/__tests__/Form.tsx +26 -0
- package/class-validator/src/__tests__/__fixtures__/data.ts +1 -1
- package/class-validator/src/__tests__/class-validator.ts +22 -11
- package/class-validator/src/class-validator.ts +47 -13
- package/class-validator/src/index.ts +0 -1
- package/computed-types/dist/computed-types.d.ts +18 -2
- package/computed-types/dist/computed-types.js.map +1 -1
- package/computed-types/dist/computed-types.mjs +1 -1
- package/computed-types/dist/computed-types.modern.mjs +1 -1
- package/computed-types/dist/computed-types.modern.mjs.map +1 -1
- package/computed-types/dist/computed-types.module.js +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/dist/index.d.ts +0 -1
- package/computed-types/src/__tests__/Form-native-validation.tsx +2 -4
- package/computed-types/src/__tests__/Form.tsx +30 -6
- package/computed-types/src/__tests__/__fixtures__/data.ts +1 -1
- package/computed-types/src/__tests__/computed-types.ts +2 -0
- package/computed-types/src/computed-types.ts +24 -7
- package/computed-types/src/index.ts +0 -1
- package/dist/resolvers.js +1 -1
- package/dist/resolvers.js.map +1 -1
- package/dist/resolvers.mjs +1 -1
- package/dist/resolvers.mjs.map +1 -1
- package/dist/resolvers.module.js +1 -1
- package/dist/resolvers.module.js.map +1 -1
- package/dist/resolvers.umd.js +1 -1
- package/dist/resolvers.umd.js.map +1 -1
- package/effect-ts/dist/effect-ts.d.ts +19 -2
- package/effect-ts/dist/effect-ts.js +1 -1
- package/effect-ts/dist/effect-ts.js.map +1 -1
- package/effect-ts/dist/effect-ts.mjs +1 -1
- package/effect-ts/dist/effect-ts.modern.mjs +1 -1
- package/effect-ts/dist/effect-ts.modern.mjs.map +1 -1
- package/effect-ts/dist/effect-ts.module.js +1 -1
- package/effect-ts/dist/effect-ts.module.js.map +1 -1
- package/effect-ts/dist/effect-ts.umd.js +1 -1
- package/effect-ts/dist/effect-ts.umd.js.map +1 -1
- package/effect-ts/dist/index.d.ts +0 -1
- package/effect-ts/src/__tests__/Form.tsx +30 -4
- package/effect-ts/src/__tests__/__fixtures__/data.ts +1 -1
- package/effect-ts/src/__tests__/__snapshots__/effect-ts.ts.snap +35 -1
- package/effect-ts/src/__tests__/effect-ts.ts +61 -0
- package/effect-ts/src/effect-ts.ts +60 -13
- package/effect-ts/src/index.ts +0 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.d.ts +21 -0
- package/fluentvalidation-ts/dist/fluentvalidation-ts.js +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.js.map +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.mjs +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.modern.mjs +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.modern.mjs.map +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.module.js +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.module.js.map +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.umd.js +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.umd.js.map +1 -1
- package/fluentvalidation-ts/src/fluentvalidation-ts.ts +24 -3
- package/io-ts/dist/errorsToRecord.d.ts +5 -1
- package/io-ts/dist/index.d.ts +0 -1
- package/io-ts/dist/io-ts.d.ts +19 -2
- package/io-ts/dist/io-ts.js +1 -1
- package/io-ts/dist/io-ts.js.map +1 -1
- package/io-ts/dist/io-ts.mjs +1 -1
- package/io-ts/dist/io-ts.modern.mjs +1 -1
- package/io-ts/dist/io-ts.modern.mjs.map +1 -1
- package/io-ts/dist/io-ts.module.js +1 -1
- package/io-ts/dist/io-ts.module.js.map +1 -1
- package/io-ts/dist/io-ts.umd.js +1 -1
- package/io-ts/dist/io-ts.umd.js.map +1 -1
- package/io-ts/src/__tests__/Form-native-validation.tsx +4 -11
- package/io-ts/src/__tests__/Form.tsx +30 -6
- package/io-ts/src/__tests__/__fixtures__/data.ts +2 -19
- package/io-ts/src/errorsToRecord.ts +4 -1
- package/io-ts/src/index.ts +0 -1
- package/io-ts/src/io-ts.ts +47 -25
- package/joi/dist/joi.d.ts +17 -0
- 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/joi/src/joi.ts +17 -0
- package/nope/dist/nope.d.ts +17 -0
- package/nope/dist/nope.js +1 -1
- package/nope/dist/nope.js.map +1 -1
- package/nope/dist/nope.mjs +1 -1
- package/nope/dist/nope.modern.mjs.map +1 -1
- package/nope/dist/nope.module.js +1 -1
- package/nope/dist/nope.module.js.map +1 -1
- package/nope/dist/nope.umd.js +1 -1
- package/nope/dist/nope.umd.js.map +1 -1
- package/nope/src/nope.ts +17 -0
- package/package.json +49 -34
- package/standard-schema/dist/index.d.ts +1 -0
- package/standard-schema/dist/standard-schema.d.ts +25 -0
- package/standard-schema/dist/standard-schema.js +2 -0
- package/standard-schema/dist/standard-schema.js.map +1 -0
- package/standard-schema/dist/standard-schema.mjs +2 -0
- package/standard-schema/dist/standard-schema.modern.mjs +2 -0
- package/standard-schema/dist/standard-schema.modern.mjs.map +1 -0
- package/standard-schema/dist/standard-schema.module.js +2 -0
- package/standard-schema/dist/standard-schema.module.js.map +1 -0
- package/standard-schema/dist/standard-schema.umd.js +2 -0
- package/standard-schema/dist/standard-schema.umd.js.map +1 -0
- package/standard-schema/package.json +18 -0
- package/standard-schema/src/__tests__/Form-native-validation.tsx +82 -0
- package/standard-schema/src/__tests__/Form.tsx +82 -0
- package/standard-schema/src/__tests__/__fixtures__/data.ts +88 -0
- package/standard-schema/src/__tests__/__snapshots__/standard-schema.ts.snap +250 -0
- package/standard-schema/src/__tests__/standard-schema.ts +56 -0
- package/standard-schema/src/index.ts +1 -0
- package/standard-schema/src/standard-schema.ts +88 -0
- package/superstruct/dist/index.d.ts +0 -1
- package/superstruct/dist/superstruct.d.ts +22 -2
- package/superstruct/dist/superstruct.js +1 -1
- package/superstruct/dist/superstruct.js.map +1 -1
- package/superstruct/dist/superstruct.mjs +1 -1
- package/superstruct/dist/superstruct.modern.mjs +1 -1
- package/superstruct/dist/superstruct.modern.mjs.map +1 -1
- package/superstruct/dist/superstruct.module.js +1 -1
- package/superstruct/dist/superstruct.module.js.map +1 -1
- package/superstruct/dist/superstruct.umd.js +1 -1
- package/superstruct/dist/superstruct.umd.js.map +1 -1
- package/superstruct/src/__tests__/Form.tsx +26 -0
- package/superstruct/src/__tests__/__fixtures__/data.ts +1 -1
- package/superstruct/src/index.ts +0 -1
- package/superstruct/src/superstruct.ts +32 -10
- package/typanion/dist/index.d.ts +0 -1
- package/typanion/dist/typanion.d.ts +18 -2
- package/typanion/dist/typanion.js.map +1 -1
- package/typanion/dist/typanion.mjs +1 -1
- package/typanion/dist/typanion.modern.mjs +1 -1
- package/typanion/dist/typanion.modern.mjs.map +1 -1
- package/typanion/dist/typanion.module.js +1 -1
- package/typanion/dist/typanion.module.js.map +1 -1
- package/typanion/dist/typanion.umd.js.map +1 -1
- package/typanion/src/__tests__/Form-native-validation.tsx +6 -14
- package/typanion/src/__tests__/Form.tsx +32 -8
- package/typanion/src/__tests__/__fixtures__/data.ts +9 -9
- package/typanion/src/__tests__/typanion.ts +3 -3
- package/typanion/src/index.ts +0 -1
- package/typanion/src/typanion.ts +32 -9
- package/typebox/dist/index.d.ts +0 -1
- package/typebox/dist/typebox.d.ts +20 -2
- package/typebox/dist/typebox.js +1 -1
- package/typebox/dist/typebox.js.map +1 -1
- package/typebox/dist/typebox.mjs +1 -1
- package/typebox/dist/typebox.modern.mjs +1 -1
- package/typebox/dist/typebox.modern.mjs.map +1 -1
- package/typebox/dist/typebox.module.js +1 -1
- package/typebox/dist/typebox.module.js.map +1 -1
- package/typebox/dist/typebox.umd.js +1 -1
- package/typebox/dist/typebox.umd.js.map +1 -1
- package/typebox/src/__tests__/Form-compiler.tsx +4 -8
- package/typebox/src/__tests__/Form.tsx +32 -6
- package/typebox/src/__tests__/__fixtures__/data.ts +1 -1
- package/typebox/src/__tests__/__snapshots__/typebox-compiler.ts.snap +21 -21
- package/typebox/src/__tests__/__snapshots__/typebox.ts.snap +21 -21
- package/typebox/src/index.ts +0 -1
- package/typebox/src/typebox.ts +33 -7
- package/typeschema/dist/typeschema.d.ts +17 -0
- 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/typeschema.ts +20 -1
- package/valibot/dist/index.d.ts +0 -1
- package/valibot/dist/valibot.d.ts +31 -2
- package/valibot/dist/valibot.js +1 -1
- package/valibot/dist/valibot.js.map +1 -1
- package/valibot/dist/valibot.mjs +1 -1
- package/valibot/dist/valibot.modern.mjs +1 -1
- package/valibot/dist/valibot.modern.mjs.map +1 -1
- package/valibot/dist/valibot.module.js +1 -1
- package/valibot/dist/valibot.module.js.map +1 -1
- package/valibot/dist/valibot.umd.js +1 -1
- package/valibot/dist/valibot.umd.js.map +1 -1
- package/valibot/package.json +1 -1
- package/valibot/src/__tests__/Form.tsx +26 -0
- package/valibot/src/__tests__/__fixtures__/data.ts +7 -3
- package/valibot/src/__tests__/valibot.ts +1 -1
- package/valibot/src/index.ts +0 -1
- package/valibot/src/valibot.ts +55 -6
- package/vest/dist/vest.d.ts +18 -0
- 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/vest/src/vest.ts +18 -0
- package/vine/dist/index.d.ts +0 -1
- package/vine/dist/vine.d.ts +25 -2
- package/vine/dist/vine.js +1 -1
- package/vine/dist/vine.js.map +1 -1
- package/vine/dist/vine.mjs +1 -1
- package/vine/dist/vine.modern.mjs +1 -1
- package/vine/dist/vine.modern.mjs.map +1 -1
- package/vine/dist/vine.module.js +1 -1
- package/vine/dist/vine.module.js.map +1 -1
- package/vine/dist/vine.umd.js +1 -1
- package/vine/dist/vine.umd.js.map +1 -1
- package/vine/src/__tests__/Form-native-validation.tsx +2 -4
- package/vine/src/__tests__/Form.tsx +30 -6
- package/vine/src/__tests__/__fixtures__/data.ts +1 -1
- package/vine/src/index.ts +0 -1
- package/vine/src/vine.ts +38 -10
- package/yup/dist/yup.d.ts +18 -7
- package/yup/dist/yup.js +1 -1
- package/yup/dist/yup.js.map +1 -1
- package/yup/dist/yup.mjs +1 -1
- package/yup/dist/yup.modern.mjs +1 -1
- package/yup/dist/yup.modern.mjs.map +1 -1
- package/yup/dist/yup.module.js +1 -1
- package/yup/dist/yup.module.js.map +1 -1
- package/yup/dist/yup.umd.js +1 -1
- package/yup/dist/yup.umd.js.map +1 -1
- package/yup/src/yup.ts +22 -11
- package/zod/dist/index.d.ts +0 -1
- package/zod/dist/zod.d.ts +25 -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__/Form.tsx +30 -6
- package/zod/src/__tests__/__fixtures__/data.ts +3 -3
- package/zod/src/index.ts +0 -1
- package/zod/src/zod.ts +40 -9
- package/arktype/dist/types.d.ts +0 -9
- package/arktype/src/types.ts +0 -18
- package/class-validator/dist/types.d.ts +0 -12
- package/class-validator/src/types.ts +0 -16
- package/computed-types/dist/types.d.ts +0 -2
- package/computed-types/src/types.ts +0 -13
- package/effect-ts/dist/types.d.ts +0 -4
- package/effect-ts/src/types.ts +0 -12
- package/io-ts/dist/types.d.ts +0 -7
- package/io-ts/src/types.ts +0 -18
- package/superstruct/dist/types.d.ts +0 -11
- package/superstruct/src/types.ts +0 -20
- package/typanion/dist/types.d.ts +0 -9
- package/typanion/src/types.ts +0 -20
- package/typebox/dist/types.d.ts +0 -4
- package/typebox/src/types.ts +0 -11
- package/valibot/dist/types.d.ts +0 -13
- package/valibot/src/types.ts +0 -34
- package/vine/dist/types.d.ts +0 -6
- package/vine/src/types.ts +0 -13
- package/zod/dist/types.d.ts +0 -13
- package/zod/src/types.ts +0 -22
|
@@ -3,463 +3,70 @@
|
|
|
3
3
|
exports[`arktypeResolver > should return a single error from arktypeResolver when validation fails 1`] = `
|
|
4
4
|
{
|
|
5
5
|
"errors": {
|
|
6
|
-
"accessToken":
|
|
7
|
-
"
|
|
8
|
-
"data": {
|
|
9
|
-
"birthYear": "birthYear",
|
|
10
|
-
"email": "",
|
|
11
|
-
"like": [
|
|
12
|
-
{
|
|
13
|
-
"id": "z",
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
"password": "___",
|
|
17
|
-
"url": "abc",
|
|
18
|
-
},
|
|
19
|
-
"input": {
|
|
20
|
-
"code": "required",
|
|
21
|
-
"missingValueDescription": "a number or a string",
|
|
22
|
-
"relativePath": [
|
|
23
|
-
"accessToken",
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
"missingValueDescription": "a number or a string",
|
|
27
|
-
"nodeConfig": {
|
|
28
|
-
"actual": [Function],
|
|
29
|
-
"description": [Function],
|
|
30
|
-
"expected": [Function],
|
|
31
|
-
"message": [Function],
|
|
32
|
-
"problem": [Function],
|
|
33
|
-
},
|
|
34
|
-
"path": [
|
|
35
|
-
"accessToken",
|
|
36
|
-
],
|
|
6
|
+
"accessToken": {
|
|
7
|
+
"message": "accessToken must be a number or a string (was missing)",
|
|
37
8
|
"ref": undefined,
|
|
38
|
-
"relativePath": [
|
|
39
|
-
"accessToken",
|
|
40
|
-
],
|
|
41
9
|
"type": "required",
|
|
42
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
43
10
|
},
|
|
44
|
-
"birthYear":
|
|
45
|
-
"
|
|
46
|
-
"data": "birthYear",
|
|
47
|
-
"description": "a number",
|
|
48
|
-
"domain": "number",
|
|
49
|
-
"input": {
|
|
50
|
-
"code": "domain",
|
|
51
|
-
"description": "a number",
|
|
52
|
-
"domain": "number",
|
|
53
|
-
},
|
|
54
|
-
"nodeConfig": {
|
|
55
|
-
"actual": [Function],
|
|
56
|
-
"description": [Function],
|
|
57
|
-
"expected": [Function],
|
|
58
|
-
"message": [Function],
|
|
59
|
-
"problem": [Function],
|
|
60
|
-
},
|
|
61
|
-
"path": [
|
|
62
|
-
"birthYear",
|
|
63
|
-
],
|
|
11
|
+
"birthYear": {
|
|
12
|
+
"message": "birthYear must be a number (was a string)",
|
|
64
13
|
"ref": undefined,
|
|
65
14
|
"type": "domain",
|
|
66
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
67
15
|
},
|
|
68
|
-
"dateStr":
|
|
69
|
-
"
|
|
70
|
-
"data": {
|
|
71
|
-
"birthYear": "birthYear",
|
|
72
|
-
"email": "",
|
|
73
|
-
"like": [
|
|
74
|
-
{
|
|
75
|
-
"id": "z",
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
"password": "___",
|
|
79
|
-
"url": "abc",
|
|
80
|
-
},
|
|
81
|
-
"input": {
|
|
82
|
-
"code": "required",
|
|
83
|
-
"missingValueDescription": "a Date",
|
|
84
|
-
"relativePath": [
|
|
85
|
-
"dateStr",
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
"missingValueDescription": "a Date",
|
|
89
|
-
"nodeConfig": {
|
|
90
|
-
"actual": [Function],
|
|
91
|
-
"description": [Function],
|
|
92
|
-
"expected": [Function],
|
|
93
|
-
"message": [Function],
|
|
94
|
-
"problem": [Function],
|
|
95
|
-
},
|
|
96
|
-
"path": [
|
|
97
|
-
"dateStr",
|
|
98
|
-
],
|
|
16
|
+
"dateStr": {
|
|
17
|
+
"message": "dateStr must be a Date (was missing)",
|
|
99
18
|
"ref": undefined,
|
|
100
|
-
"relativePath": [
|
|
101
|
-
"dateStr",
|
|
102
|
-
],
|
|
103
19
|
"type": "required",
|
|
104
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
105
20
|
},
|
|
106
|
-
"email":
|
|
107
|
-
"
|
|
108
|
-
"data": "",
|
|
109
|
-
"description": "a valid email",
|
|
110
|
-
"flags": "",
|
|
111
|
-
"input": {
|
|
112
|
-
"code": "pattern",
|
|
113
|
-
"description": "a valid email",
|
|
114
|
-
"flags": "",
|
|
115
|
-
"rule": "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$",
|
|
116
|
-
},
|
|
117
|
-
"nodeConfig": {
|
|
118
|
-
"actual": [Function],
|
|
119
|
-
"description": [Function],
|
|
120
|
-
"expected": [Function],
|
|
121
|
-
"message": [Function],
|
|
122
|
-
"problem": [Function],
|
|
123
|
-
},
|
|
124
|
-
"path": [
|
|
125
|
-
"email",
|
|
126
|
-
],
|
|
21
|
+
"email": {
|
|
22
|
+
"message": "email must be an email address (was "")",
|
|
127
23
|
"ref": {
|
|
128
24
|
"name": "email",
|
|
129
25
|
},
|
|
130
|
-
"rule": "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$",
|
|
131
26
|
"type": "pattern",
|
|
132
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
133
27
|
},
|
|
134
|
-
"enabled":
|
|
135
|
-
"
|
|
136
|
-
"data": {
|
|
137
|
-
"birthYear": "birthYear",
|
|
138
|
-
"email": "",
|
|
139
|
-
"like": [
|
|
140
|
-
{
|
|
141
|
-
"id": "z",
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
"password": "___",
|
|
145
|
-
"url": "abc",
|
|
146
|
-
},
|
|
147
|
-
"input": {
|
|
148
|
-
"code": "required",
|
|
149
|
-
"missingValueDescription": "boolean",
|
|
150
|
-
"relativePath": [
|
|
151
|
-
"enabled",
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
"missingValueDescription": "boolean",
|
|
155
|
-
"nodeConfig": {
|
|
156
|
-
"actual": [Function],
|
|
157
|
-
"description": [Function],
|
|
158
|
-
"expected": [Function],
|
|
159
|
-
"message": [Function],
|
|
160
|
-
"problem": [Function],
|
|
161
|
-
},
|
|
162
|
-
"path": [
|
|
163
|
-
"enabled",
|
|
164
|
-
],
|
|
28
|
+
"enabled": {
|
|
29
|
+
"message": "enabled must be boolean (was missing)",
|
|
165
30
|
"ref": undefined,
|
|
166
|
-
"relativePath": [
|
|
167
|
-
"enabled",
|
|
168
|
-
],
|
|
169
31
|
"type": "required",
|
|
170
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
171
32
|
},
|
|
172
33
|
"like": [
|
|
173
34
|
{
|
|
174
|
-
"id":
|
|
175
|
-
"
|
|
176
|
-
"data": "z",
|
|
177
|
-
"description": "a number",
|
|
178
|
-
"domain": "number",
|
|
179
|
-
"input": {
|
|
180
|
-
"code": "domain",
|
|
181
|
-
"description": "a number",
|
|
182
|
-
"domain": "number",
|
|
183
|
-
},
|
|
184
|
-
"nodeConfig": {
|
|
185
|
-
"actual": [Function],
|
|
186
|
-
"description": [Function],
|
|
187
|
-
"expected": [Function],
|
|
188
|
-
"message": [Function],
|
|
189
|
-
"problem": [Function],
|
|
190
|
-
},
|
|
191
|
-
"path": [
|
|
192
|
-
"like",
|
|
193
|
-
0,
|
|
194
|
-
"id",
|
|
195
|
-
],
|
|
35
|
+
"id": {
|
|
36
|
+
"message": "like[0].id must be a number (was a string)",
|
|
196
37
|
"ref": undefined,
|
|
197
38
|
"type": "domain",
|
|
198
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
199
39
|
},
|
|
200
|
-
"name":
|
|
201
|
-
"
|
|
202
|
-
"data": {
|
|
203
|
-
"id": "z",
|
|
204
|
-
},
|
|
205
|
-
"input": {
|
|
206
|
-
"code": "required",
|
|
207
|
-
"missingValueDescription": "a string",
|
|
208
|
-
"relativePath": [
|
|
209
|
-
"name",
|
|
210
|
-
],
|
|
211
|
-
},
|
|
212
|
-
"missingValueDescription": "a string",
|
|
213
|
-
"nodeConfig": {
|
|
214
|
-
"actual": [Function],
|
|
215
|
-
"description": [Function],
|
|
216
|
-
"expected": [Function],
|
|
217
|
-
"message": [Function],
|
|
218
|
-
"problem": [Function],
|
|
219
|
-
},
|
|
220
|
-
"path": [
|
|
221
|
-
"like",
|
|
222
|
-
0,
|
|
223
|
-
"name",
|
|
224
|
-
],
|
|
40
|
+
"name": {
|
|
41
|
+
"message": "like[0].name must be a string (was missing)",
|
|
225
42
|
"ref": undefined,
|
|
226
|
-
"relativePath": [
|
|
227
|
-
"name",
|
|
228
|
-
],
|
|
229
43
|
"type": "required",
|
|
230
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
231
44
|
},
|
|
232
45
|
},
|
|
233
46
|
],
|
|
234
|
-
"password":
|
|
235
|
-
"
|
|
236
|
-
"data": "___",
|
|
237
|
-
"errors": [
|
|
238
|
-
ArkError {
|
|
239
|
-
"code": "pattern",
|
|
240
|
-
"data": "___",
|
|
241
|
-
"description": "matched by .*[A-Za-z].*",
|
|
242
|
-
"input": {
|
|
243
|
-
"code": "pattern",
|
|
244
|
-
"description": "matched by .*[A-Za-z].*",
|
|
245
|
-
"rule": ".*[A-Za-z].*",
|
|
246
|
-
},
|
|
247
|
-
"nodeConfig": {
|
|
248
|
-
"actual": [Function],
|
|
249
|
-
"description": [Function],
|
|
250
|
-
"expected": [Function],
|
|
251
|
-
"message": [Function],
|
|
252
|
-
"problem": [Function],
|
|
253
|
-
},
|
|
254
|
-
"path": [
|
|
255
|
-
"password",
|
|
256
|
-
],
|
|
257
|
-
"rule": ".*[A-Za-z].*",
|
|
258
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
259
|
-
},
|
|
260
|
-
ArkError {
|
|
261
|
-
"code": "pattern",
|
|
262
|
-
"data": "___",
|
|
263
|
-
"description": "matched by .*\\d.*",
|
|
264
|
-
"input": {
|
|
265
|
-
"code": "pattern",
|
|
266
|
-
"description": "matched by .*\\d.*",
|
|
267
|
-
"rule": ".*\\d.*",
|
|
268
|
-
},
|
|
269
|
-
"nodeConfig": {
|
|
270
|
-
"actual": [Function],
|
|
271
|
-
"description": [Function],
|
|
272
|
-
"expected": [Function],
|
|
273
|
-
"message": [Function],
|
|
274
|
-
"problem": [Function],
|
|
275
|
-
},
|
|
276
|
-
"path": [
|
|
277
|
-
"password",
|
|
278
|
-
],
|
|
279
|
-
"rule": ".*\\d.*",
|
|
280
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
281
|
-
},
|
|
282
|
-
],
|
|
283
|
-
"input": {
|
|
284
|
-
"code": "union",
|
|
285
|
-
"errors": [
|
|
286
|
-
ArkError {
|
|
287
|
-
"code": "pattern",
|
|
288
|
-
"data": "___",
|
|
289
|
-
"description": "matched by .*[A-Za-z].*",
|
|
290
|
-
"input": {
|
|
291
|
-
"code": "pattern",
|
|
292
|
-
"description": "matched by .*[A-Za-z].*",
|
|
293
|
-
"rule": ".*[A-Za-z].*",
|
|
294
|
-
},
|
|
295
|
-
"nodeConfig": {
|
|
296
|
-
"actual": [Function],
|
|
297
|
-
"description": [Function],
|
|
298
|
-
"expected": [Function],
|
|
299
|
-
"message": [Function],
|
|
300
|
-
"problem": [Function],
|
|
301
|
-
},
|
|
302
|
-
"path": [
|
|
303
|
-
"password",
|
|
304
|
-
],
|
|
305
|
-
"rule": ".*[A-Za-z].*",
|
|
306
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
307
|
-
},
|
|
308
|
-
ArkError {
|
|
309
|
-
"code": "pattern",
|
|
310
|
-
"data": "___",
|
|
311
|
-
"description": "matched by .*\\d.*",
|
|
312
|
-
"input": {
|
|
313
|
-
"code": "pattern",
|
|
314
|
-
"description": "matched by .*\\d.*",
|
|
315
|
-
"rule": ".*\\d.*",
|
|
316
|
-
},
|
|
317
|
-
"nodeConfig": {
|
|
318
|
-
"actual": [Function],
|
|
319
|
-
"description": [Function],
|
|
320
|
-
"expected": [Function],
|
|
321
|
-
"message": [Function],
|
|
322
|
-
"problem": [Function],
|
|
323
|
-
},
|
|
324
|
-
"path": [
|
|
325
|
-
"password",
|
|
326
|
-
],
|
|
327
|
-
"rule": ".*\\d.*",
|
|
328
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
329
|
-
},
|
|
330
|
-
],
|
|
331
|
-
},
|
|
332
|
-
"nodeConfig": {
|
|
333
|
-
"actual": [Function],
|
|
334
|
-
"description": [Function],
|
|
335
|
-
"expected": [Function],
|
|
336
|
-
"message": [Function],
|
|
337
|
-
"problem": [Function],
|
|
338
|
-
},
|
|
339
|
-
"path": [
|
|
340
|
-
"password",
|
|
341
|
-
],
|
|
47
|
+
"password": {
|
|
48
|
+
"message": "password must be matched by .*[A-Za-z].* or matched by .*\\d.* (was "___")",
|
|
342
49
|
"ref": {
|
|
343
50
|
"name": "password",
|
|
344
51
|
},
|
|
345
52
|
"type": "union",
|
|
346
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
347
53
|
},
|
|
348
|
-
"repeatPassword":
|
|
349
|
-
"
|
|
350
|
-
"data": {
|
|
351
|
-
"birthYear": "birthYear",
|
|
352
|
-
"email": "",
|
|
353
|
-
"like": [
|
|
354
|
-
{
|
|
355
|
-
"id": "z",
|
|
356
|
-
},
|
|
357
|
-
],
|
|
358
|
-
"password": "___",
|
|
359
|
-
"url": "abc",
|
|
360
|
-
},
|
|
361
|
-
"input": {
|
|
362
|
-
"code": "required",
|
|
363
|
-
"missingValueDescription": "a string",
|
|
364
|
-
"relativePath": [
|
|
365
|
-
"repeatPassword",
|
|
366
|
-
],
|
|
367
|
-
},
|
|
368
|
-
"missingValueDescription": "a string",
|
|
369
|
-
"nodeConfig": {
|
|
370
|
-
"actual": [Function],
|
|
371
|
-
"description": [Function],
|
|
372
|
-
"expected": [Function],
|
|
373
|
-
"message": [Function],
|
|
374
|
-
"problem": [Function],
|
|
375
|
-
},
|
|
376
|
-
"path": [
|
|
377
|
-
"repeatPassword",
|
|
378
|
-
],
|
|
54
|
+
"repeatPassword": {
|
|
55
|
+
"message": "repeatPassword must be a string (was missing)",
|
|
379
56
|
"ref": undefined,
|
|
380
|
-
"relativePath": [
|
|
381
|
-
"repeatPassword",
|
|
382
|
-
],
|
|
383
57
|
"type": "required",
|
|
384
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
385
58
|
},
|
|
386
|
-
"tags":
|
|
387
|
-
"
|
|
388
|
-
"data": {
|
|
389
|
-
"birthYear": "birthYear",
|
|
390
|
-
"email": "",
|
|
391
|
-
"like": [
|
|
392
|
-
{
|
|
393
|
-
"id": "z",
|
|
394
|
-
},
|
|
395
|
-
],
|
|
396
|
-
"password": "___",
|
|
397
|
-
"url": "abc",
|
|
398
|
-
},
|
|
399
|
-
"input": {
|
|
400
|
-
"code": "required",
|
|
401
|
-
"missingValueDescription": "an array",
|
|
402
|
-
"relativePath": [
|
|
403
|
-
"tags",
|
|
404
|
-
],
|
|
405
|
-
},
|
|
406
|
-
"missingValueDescription": "an array",
|
|
407
|
-
"nodeConfig": {
|
|
408
|
-
"actual": [Function],
|
|
409
|
-
"description": [Function],
|
|
410
|
-
"expected": [Function],
|
|
411
|
-
"message": [Function],
|
|
412
|
-
"problem": [Function],
|
|
413
|
-
},
|
|
414
|
-
"path": [
|
|
415
|
-
"tags",
|
|
416
|
-
],
|
|
59
|
+
"tags": {
|
|
60
|
+
"message": "tags must be an array (was missing)",
|
|
417
61
|
"ref": undefined,
|
|
418
|
-
"relativePath": [
|
|
419
|
-
"tags",
|
|
420
|
-
],
|
|
421
62
|
"type": "required",
|
|
422
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
423
63
|
},
|
|
424
|
-
"username":
|
|
425
|
-
"
|
|
426
|
-
"data": {
|
|
427
|
-
"birthYear": "birthYear",
|
|
428
|
-
"email": "",
|
|
429
|
-
"like": [
|
|
430
|
-
{
|
|
431
|
-
"id": "z",
|
|
432
|
-
},
|
|
433
|
-
],
|
|
434
|
-
"password": "___",
|
|
435
|
-
"url": "abc",
|
|
436
|
-
},
|
|
437
|
-
"input": {
|
|
438
|
-
"code": "required",
|
|
439
|
-
"missingValueDescription": "a string",
|
|
440
|
-
"relativePath": [
|
|
441
|
-
"username",
|
|
442
|
-
],
|
|
443
|
-
},
|
|
444
|
-
"missingValueDescription": "a string",
|
|
445
|
-
"nodeConfig": {
|
|
446
|
-
"actual": [Function],
|
|
447
|
-
"description": [Function],
|
|
448
|
-
"expected": [Function],
|
|
449
|
-
"message": [Function],
|
|
450
|
-
"problem": [Function],
|
|
451
|
-
},
|
|
452
|
-
"path": [
|
|
453
|
-
"username",
|
|
454
|
-
],
|
|
64
|
+
"username": {
|
|
65
|
+
"message": "username must be a string (was missing)",
|
|
455
66
|
"ref": {
|
|
456
67
|
"name": "username",
|
|
457
68
|
},
|
|
458
|
-
"relativePath": [
|
|
459
|
-
"username",
|
|
460
|
-
],
|
|
461
69
|
"type": "required",
|
|
462
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
463
70
|
},
|
|
464
71
|
},
|
|
465
72
|
"values": {},
|
package/arktype/src/arktype.ts
CHANGED
|
@@ -1,18 +1,48 @@
|
|
|
1
1
|
import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
|
|
2
|
-
import { ArkErrors } from 'arktype';
|
|
3
|
-
import { FieldError, FieldErrors } from 'react-hook-form';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import { ArkErrors, Type } from 'arktype';
|
|
3
|
+
import { FieldError, FieldErrors, Resolver } from 'react-hook-form';
|
|
4
|
+
|
|
5
|
+
function parseErrorSchema(arkErrors: ArkErrors): Record<string, FieldError> {
|
|
6
|
+
const errors = [...arkErrors];
|
|
7
|
+
const fieldsErrors: Record<string, FieldError> = {};
|
|
8
|
+
|
|
9
|
+
for (; errors.length; ) {
|
|
10
|
+
const error = errors[0];
|
|
11
|
+
const _path = error.path.join('.');
|
|
12
|
+
|
|
13
|
+
if (!fieldsErrors[_path]) {
|
|
14
|
+
fieldsErrors[_path] = { message: error.message, type: error.code };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
errors.shift();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return fieldsErrors;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a resolver for react-hook-form using Arktype schema validation
|
|
25
|
+
* @param {Schema} schema - The Arktype schema to validate against
|
|
26
|
+
* @param {Object} resolverOptions - Additional resolver configuration
|
|
27
|
+
* @param {string} [resolverOptions.mode='raw'] - Return the raw input values rather than the parsed values
|
|
28
|
+
* @returns {Resolver<Schema['inferOut']>} A resolver function compatible with react-hook-form
|
|
29
|
+
* @example
|
|
30
|
+
* const schema = type({
|
|
31
|
+
* username: 'string>2'
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* useForm({
|
|
35
|
+
* resolver: arktypeResolver(schema)
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
38
|
+
export function arktypeResolver<Schema extends Type<any, any>>(
|
|
39
|
+
schema: Schema,
|
|
40
|
+
_schemaOptions?: never,
|
|
41
|
+
resolverOptions: {
|
|
42
|
+
raw?: boolean;
|
|
43
|
+
} = {},
|
|
44
|
+
): Resolver<Schema['inferOut']> {
|
|
45
|
+
return (values, _, options) => {
|
|
16
46
|
const out = schema(values);
|
|
17
47
|
|
|
18
48
|
if (out instanceof ArkErrors) {
|
|
@@ -26,6 +56,7 @@ export const arktypeResolver: Resolver =
|
|
|
26
56
|
|
|
27
57
|
return {
|
|
28
58
|
errors: {} as FieldErrors,
|
|
29
|
-
values: resolverOptions.raw ? values : out,
|
|
59
|
+
values: resolverOptions.raw ? Object.assign({}, values) : out,
|
|
30
60
|
};
|
|
31
61
|
};
|
|
62
|
+
}
|
package/arktype/src/index.ts
CHANGED
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { ClassConstructor, ClassTransformOptions } from 'class-transformer';
|
|
2
|
+
import { ValidatorOptions } from 'class-validator';
|
|
3
|
+
import { Resolver } from 'react-hook-form';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a resolver for react-hook-form using class-validator schema validation
|
|
6
|
+
* @param {ClassConstructor<Schema>} schema - The class-validator schema to validate against
|
|
7
|
+
* @param {Object} schemaOptions - Additional schema validation options
|
|
8
|
+
* @param {Object} resolverOptions - Additional resolver configuration
|
|
9
|
+
* @param {string} [resolverOptions.mode='async'] - Validation mode
|
|
10
|
+
* @returns {Resolver<Schema>} A resolver function compatible with react-hook-form
|
|
11
|
+
* @example
|
|
12
|
+
* class Schema {
|
|
13
|
+
* @Matches(/^\w+$/)
|
|
14
|
+
* @Length(3, 30)
|
|
15
|
+
* username: string;
|
|
16
|
+
* age: number
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* useForm({
|
|
20
|
+
* resolver: classValidatorResolver(Schema)
|
|
21
|
+
* });
|
|
22
|
+
*/
|
|
23
|
+
export declare function classValidatorResolver<Schema extends Record<string, any>>(schema: ClassConstructor<Schema>, schemaOptions?: {
|
|
24
|
+
validator?: ValidatorOptions;
|
|
25
|
+
transformer?: ClassTransformOptions;
|
|
26
|
+
}, resolverOptions?: {
|
|
27
|
+
mode?: 'async' | 'sync';
|
|
28
|
+
raw?: boolean;
|
|
29
|
+
}): Resolver<Schema>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var r=require("@hookform/resolvers"),e=require("class-transformer"),t=require("class-validator")
|
|
1
|
+
var r=require("@hookform/resolvers"),e=require("class-transformer"),t=require("class-validator");function s(r,e,t,a){return void 0===t&&(t={}),void 0===a&&(a=""),r.reduce(function(r,t){var i=a?a+"."+t.property:t.property;if(t.constraints){var o=Object.keys(t.constraints)[0];r[i]={type:o,message:t.constraints[o]};var n=r[i];e&&n&&Object.assign(n,{types:t.constraints})}return t.children&&t.children.length&&s(t.children,e,r,i),r},t)}exports.classValidatorResolver=function(a,i,o){return void 0===i&&(i={}),void 0===o&&(o={}),function(n,l,c){try{var v=i.validator,d=e.plainToClass(a,n,i.transformer);return Promise.resolve(("sync"===o.mode?t.validateSync:t.validate)(d,v)).then(function(e){return e.length?{values:{},errors:r.toNestErrors(s(e,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)}:(c.shouldUseNativeValidation&&r.validateFieldsNatively({},c),{values:o.raw?Object.assign({},n):d,errors:{}})})}catch(r){return Promise.reject(r)}}};
|
|
2
2
|
//# sourceMappingURL=class-validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-validator.js","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {
|
|
1
|
+
{"version":3,"file":"class-validator.js","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n ClassConstructor,\n ClassTransformOptions,\n plainToClass,\n} from 'class-transformer';\nimport {\n ValidationError,\n ValidatorOptions,\n validate,\n validateSync,\n} from 'class-validator';\nimport { FieldErrors, Resolver } from 'react-hook-form';\n\nfunction parseErrorSchema(\n errors: ValidationError[],\n validateAllFieldCriteria: boolean,\n parsedErrors: FieldErrors = {},\n path = '',\n) {\n return errors.reduce((acc, error) => {\n const _path = path ? `${path}.${error.property}` : error.property;\n\n if (error.constraints) {\n const key = Object.keys(error.constraints)[0];\n acc[_path] = {\n type: key,\n message: error.constraints[key],\n };\n\n const _e = acc[_path];\n if (validateAllFieldCriteria && _e) {\n Object.assign(_e, { types: error.constraints });\n }\n }\n\n if (error.children && error.children.length) {\n parseErrorSchema(error.children, validateAllFieldCriteria, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n}\n\n/**\n * Creates a resolver for react-hook-form using class-validator schema validation\n * @param {ClassConstructor<Schema>} schema - The class-validator schema to validate against\n * @param {Object} schemaOptions - Additional schema validation options\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver<Schema>} A resolver function compatible with react-hook-form\n * @example\n * class Schema {\n * @Matches(/^\\w+$/)\n * @Length(3, 30)\n * username: string;\n * age: number\n * }\n *\n * useForm({\n * resolver: classValidatorResolver(Schema)\n * });\n */\nexport function classValidatorResolver<Schema extends Record<string, any>>(\n schema: ClassConstructor<Schema>,\n schemaOptions: {\n validator?: ValidatorOptions;\n transformer?: ClassTransformOptions;\n } = {},\n resolverOptions: { mode?: 'async' | 'sync'; raw?: boolean } = {},\n): Resolver<Schema> {\n return async (values, _, options) => {\n const { transformer, validator } = schemaOptions;\n const data = plainToClass(schema, values, transformer);\n\n const rawErrors = await (resolverOptions.mode === 'sync'\n ? validateSync\n : validate)(data, validator);\n\n if (rawErrors.length) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n rawErrors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n errors: {},\n };\n };\n}\n"],"names":["parseErrorSchema","errors","validateAllFieldCriteria","parsedErrors","path","reduce","acc","error","_path","property","constraints","key","Object","keys","type","message","_e","assign","types","children","length","schema","schemaOptions","resolverOptions","values","_","options","validator","data","plainToClass","transformer","Promise","resolve","mode","validateSync","validate","then","rawErrors","toNestErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","raw","e","reject"],"mappings":"iGAcA,SAASA,EACPC,EACAC,EACAC,EACAC,GAEA,YAHA,IAAAD,IAAAA,EAA4B,CAAE,YAC9BC,IAAAA,EAAO,IAEAH,EAAOI,OAAO,SAACC,EAAKC,GACzB,IAAMC,EAAQJ,EAAUA,EAAI,IAAIG,EAAME,SAAaF,EAAME,SAEzD,GAAIF,EAAMG,YAAa,CACrB,IAAMC,EAAMC,OAAOC,KAAKN,EAAMG,aAAa,GAC3CJ,EAAIE,GAAS,CACXM,KAAMH,EACNI,QAASR,EAAMG,YAAYC,IAG7B,IAAMK,EAAKV,EAAIE,GACXN,GAA4Bc,GAC9BJ,OAAOK,OAAOD,EAAI,CAAEE,MAAOX,EAAMG,aAErC,CAMA,OAJIH,EAAMY,UAAYZ,EAAMY,SAASC,QACnCpB,EAAiBO,EAAMY,SAAUjB,EAA0BI,EAAKE,GAG3DF,CACT,EAAGH,EACL,gCAqBM,SACJkB,EACAC,EAIAC,GAEA,gBANAD,IAAAA,EAGI,CAAE,QACN,IAAAC,IAAAA,EAA8D,CAAE,GAEhE,SAAcC,EAAQC,EAAGC,OACvB,IAAqBC,EAAcL,EAAdK,UACfC,EAAOC,EAAYA,aAACR,EAAQG,EADCF,EAA3BQ,aAC+C,OAAAC,QAAAC,SAEL,SAAzBT,EAAgBU,KACrCC,eACAC,EAAAA,UAAUP,EAAMD,IAAUS,KAFxBC,SAAAA,GAIN,OAAIA,EAAUjB,OACL,CACLI,OAAQ,CAAA,EACRvB,OAAQqC,eACNtC,EACEqC,GACCX,EAAQa,2BACkB,QAAzBb,EAAQc,cAEZd,KAKNA,EAAQa,2BAA6BE,EAAsBA,uBAAC,CAAE,EAAEf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAM9B,OAAOK,OAAO,CAAE,EAAEO,GAAUI,EAC1D3B,OAAQ,CAAA,GACR,EACJ,CAAC,MAAA0C,GAAAZ,OAAAA,QAAAa,OAAAD,EACH,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as o,validate as n}from"class-validator";
|
|
1
|
+
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as o,validate as n}from"class-validator";function s(r,e,t,o){return void 0===t&&(t={}),void 0===o&&(o=""),r.reduce(function(r,t){var n=o?o+"."+t.property:t.property;if(t.constraints){var i=Object.keys(t.constraints)[0];r[n]={type:i,message:t.constraints[i]};var a=r[n];e&&a&&Object.assign(a,{types:t.constraints})}return t.children&&t.children.length&&s(t.children,e,r,n),r},t)}function i(i,a,c){return void 0===a&&(a={}),void 0===c&&(c={}),function(l,d,u){try{var v=a.validator,m=t(i,l,a.transformer);return Promise.resolve(("sync"===c.mode?o:n)(m,v)).then(function(t){return t.length?{values:{},errors:r(s(t,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)}:(u.shouldUseNativeValidation&&e({},u),{values:c.raw?Object.assign({},l):m,errors:{}})})}catch(r){return Promise.reject(r)}}}export{i as classValidatorResolver};
|
|
2
2
|
//# sourceMappingURL=class-validator.module.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as r,validateFieldsNatively as
|
|
1
|
+
import{toNestErrors as r,validateFieldsNatively as t}from"@hookform/resolvers";import{plainToClass as s}from"class-transformer";import{validateSync as e,validate as o}from"class-validator";function n(r,t,s={},e=""){return r.reduce((r,s)=>{const o=e?`${e}.${s.property}`:s.property;if(s.constraints){const e=Object.keys(s.constraints)[0];r[o]={type:e,message:s.constraints[e]};const n=r[o];t&&n&&Object.assign(n,{types:s.constraints})}return s.children&&s.children.length&&n(s.children,t,r,o),r},s)}function a(a,i={},c={}){return async(l,d,m)=>{const{transformer:u,validator:p}=i,f=s(a,l,u),h=await("sync"===c.mode?e:o)(f,p);return h.length?{values:{},errors:r(n(h,!m.shouldUseNativeValidation&&"all"===m.criteriaMode),m)}:(m.shouldUseNativeValidation&&t({},m),{values:c.raw?Object.assign({},l):f,errors:{}})}}export{a as classValidatorResolver};
|
|
2
2
|
//# sourceMappingURL=class-validator.modern.mjs.map
|